OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <svg></svg> |
| 3 <script> |
| 4 var svg = document.querySelector("svg"); |
| 5 var g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); |
| 6 var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
| 7 var attrs = { x: 100, y:100, width: 100, height: 100, fill: 'green' }; |
| 8 for (var k in attrs) |
| 9 rect.setAttribute(k, attrs[k]); |
| 10 |
| 11 var matrix = svg.createSVGMatrix().translate(-100, -100); |
| 12 g.transform.baseVal.appendItem(svg.createSVGTransformFromMatrix(matrix)); |
| 13 |
| 14 svg.appendChild(g).appendChild(rect); |
| 15 </script> |
OLD | NEW |