OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <style type="text/css"> | |
4 .cls1 { | |
5 stroke: black; | |
6 fill: rgb(0,128,255); | |
7 stroke-width: 1; | |
8 } | |
9 </style> | |
10 | |
11 <script type="text/javascript"> | |
12 function setup() { | |
13 var SHOW_BUG = true; | |
14 | |
15 var SVGNS = 'http://www.w3.org/2000/svg'; | |
16 var svg = document.createElementNS(SVGNS, "svg"); | |
17 svg.width.baseVal.valueAsString = "400px"; | |
18 svg.height.baseVal.valueAsString = "400px"; | |
19 svg.viewBox.baseVal.x = 0; | |
20 svg.viewBox.baseVal.y = 0; | |
21 svg.viewBox.baseVal.width = 200; | |
22 svg.viewBox.baseVal.height = 90; | |
23 | |
24 var path1 = document.createElementNS(SVGNS, "path"); | |
25 if (SHOW_BUG) { | |
26 path1.pathSegList.appendItem(path1.createSVGPathSegMovetoAbs(10, 10)); | |
27 path1.pathSegList.appendItem(path1.createSVGPathSegLinetoAbs(25, 15)); | |
28 path1.pathSegList.appendItem(path1.createSVGPathSegLinetoAbs(110, 75)); | |
29 path1.pathSegList.appendItem(path1.createSVGPathSegLinetoAbs(120, 90)); | |
30 path1.pathSegList.appendItem(path1.createSVGPathSegLinetoAbs(42, 42)); | |
31 path1.pathSegList.appendItem(path1.createSVGPathSegClosePath()); | |
32 } else { | |
33 path1.setAttributeNS(null, 'd', "M 10 10 L 25 15 L 110 75 L 120 90 L 42 42
Z"); | |
34 } | |
35 | |
36 path1.style.setProperty("stroke", "black", ""); | |
37 path1.style.setProperty("fill", "red", ""); | |
38 var path2 = path1.cloneNode(true); | |
39 path2.setAttributeNS(null, 'transform', "translate(75, 0)"); | |
40 | |
41 var drawing = document.getElementById("drawing"); | |
42 svg.appendChild(path1); | |
43 svg.appendChild(path2); | |
44 drawing.appendChild(svg); | |
45 } | |
46 </script> | |
47 </head> | |
48 <body onload="setup()"> | |
49 <p>Below is a JavaScript-generated svg drawing. You should see two red blobs: th
e left, a programmatically generated path and the right, its clone.</p> | |
50 <div id="drawing"></div> | |
51 </body> | |
52 </html> | |
53 | |
54 | |
OLD | NEW |