From b219848f504eebd11015032b1ea3f77ef399a656 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Wed, 29 Jun 2016 12:14:01 +0200 Subject: [PATCH] try to draw 1000*1000 svg grig --- src/arenas/tron/js.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/arenas/tron/js.js b/src/arenas/tron/js.js index 11596b6..ae9e2f8 100644 --- a/src/arenas/tron/js.js +++ b/src/arenas/tron/js.js @@ -4,15 +4,20 @@ function createElem(type,attributes){ {elem.setAttribute(i,attributes[i]);} return elem; } - +function createElemNs(type,attributes){ + var elem=document.createElement(type); + for (var i in attributes) + {elem.setAttributeNs(i,attributes[i]);} + return elem; +} function tron(bot1,bot2,xdcheck){ - var mapImg = document.getElementById("map"); - - var rect=createElem('rect',{'x':'10','y':'10','width':'50','height':'80','style':'stroke:#000000; fill:none;'}); + var svg = document.getElementById("map"); + var svgDoc = svg.contentDocument; + var rect=createElemNs('rect',{'x':'10','y':'10','width':'50','height':'80','style':'stroke:#000000; fill:none;'}); - mapImg.appendChild(rect); + svgDoc.appendChild(rect); }