| OLD | NEW |
| (Empty) |
| 1 description("Test different constructors of Path."); | |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | |
| 3 | |
| 4 debug("Test constructor Path().") | |
| 5 ctx.beginPath(); | |
| 6 var p1 = new Path2D(); | |
| 7 p1.rect(0,0,100,100); | |
| 8 ctx.fillStyle = 'yellow'; | |
| 9 ctx.fill(p1); | |
| 10 var imageData = ctx.getImageData(0, 0, 100, 100); | |
| 11 var imgdata = imageData.data; | |
| 12 shouldBe("imgdata[4]", "255"); | |
| 13 shouldBe("imgdata[5]", "255"); | |
| 14 shouldBe("imgdata[6]", "0"); | |
| 15 shouldBe("imgdata[7]", "255"); | |
| 16 debug(""); | |
| 17 | |
| 18 debug("Test constructor Path(DOMString) which takes a SVG data string.") | |
| 19 ctx.beginPath(); | |
| 20 var p2 = new Path2D("M100,0L200,0L200,100L100,100z"); | |
| 21 ctx.fillStyle = 'blue'; | |
| 22 ctx.fill(p2); | |
| 23 imageData = ctx.getImageData(100, 0, 100, 100); | |
| 24 imgdata = imageData.data; | |
| 25 shouldBe("imgdata[4]", "0"); | |
| 26 shouldBe("imgdata[5]", "0"); | |
| 27 shouldBe("imgdata[6]", "255"); | |
| 28 shouldBe("imgdata[7]", "255"); | |
| 29 debug(""); | |
| 30 | |
| 31 debug("Test constructor Path(Path) which takes another Path object.") | |
| 32 ctx.beginPath(); | |
| 33 var p3 = new Path2D(p1); | |
| 34 ctx.translate(200,0); | |
| 35 ctx.fillStyle = 'green'; | |
| 36 ctx.fill(p3); | |
| 37 ctx.translate(-200,0); | |
| 38 imageData = ctx.getImageData(200, 0, 100, 100); | |
| 39 imgdata = imageData.data; | |
| 40 shouldBe("imgdata[4]", "0"); | |
| 41 shouldBe("imgdata[5]", "128"); | |
| 42 shouldBe("imgdata[6]", "0"); | |
| 43 shouldBe("imgdata[7]", "255"); | |
| 44 debug(""); | |
| OLD | NEW |