Initially, I had built-in svg, which works the way I wanted.
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="smallGrid" width="10" height="10" patternUnits="userSpaceOnUse">
<path d="M 10 0 L 0 0 0 10" fill="none" stroke="gray" stroke-width="0.5"/>
</pattern>
<pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse">
<rect width="100" height="100" fill="url(#smallGrid)"/>
<path d="M 100 0 L 0 0 0 100" fill="none" stroke="gray" stroke-width="1"/>
</pattern>
</defs>
<rect width="100%" height="100%" fill="url(#grid)" />
</svg>
and was nice because it was inline, I could use the jQuery selector to wrap it: Width / Height and path.d attributes.
so it was an overlay div that didn't do what i wanted.
In the next step, I thought to save it as an svg file, and then refer to it:
<div style="background-image:url('images/grid.svg');"></div>
for me it was PERFECT because I took something already existing and gave it a background instead of having a complete new div with data.
The problem with the background image route is that I cannot dynamically adjust the Height / Width / path.d attributes
Is there any way that I can get the best of both worlds?
background-image + being able to query and update the attributes?
, set_gridSize:
Form.set_gridSize = function (num) {
num = Number(num);
Form.gridSize = num;
var defs = $("div.grid-for-gridlock > svg > defs");
defs.children("#smallGrid").attr({ Height: num, Width: num });
var path = defs.children("#smallGrid").children().attr("d");
var arr = path.split(" ");
arr[1] = num;
arr[arr.length - 1] = num;
path = arr.join(" ");
defs.children("#smallGrid").children("path").attr("d", path)
defs.children("#grid").attr({ Height: num * 10, Width: num * 10 });
defs.children("#grid").children("rect").attr({ eight: num * 10, Width: num * 10 });
var path = defs.children("#grid").children("path").attr("d");
var arr = path.split(" ");
arr[1] = num*10;
arr[arr.length - 1] = num*10;
path = arr.join(" ");
defs.children("#grid").children("path").attr("d",path);
}
!:)
edit: html5 (canvas svg) SVG html5 .