Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 description("Test addPath() method."); | |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | |
| 3 | |
| 4 debug("Test addPath() with transform as identity matrix.") | |
| 5 ctx.beginPath(); | |
| 6 var p1 = new Path(); | |
| 7 p1.rect(0,0,100,100); | |
| 8 var p2 = new Path(); | |
| 9 p2.rect(0,100,100,100); | |
| 10 var m = ctx.currentTransform; | |
| 11 p1.addPath(p2, m); | |
| 12 ctx.fillStyle = 'yellow'; | |
| 13 ctx.currentPath = p1; | |
| 14 ctx.fill(); | |
| 15 var imageData = ctx.getImageData(0, 100, 100, 100); | |
| 16 var imgdata = imageData.data; | |
| 17 shouldBe("imgdata[4]", "255"); | |
| 18 shouldBe("imgdata[5]", "255"); | |
| 19 shouldBe("imgdata[6]", "0"); | |
| 20 shouldBe("imgdata[7]", "255"); | |
| 21 debug(""); | |
| 22 | |
| 23 debug("Test addPath() with transform as translate(100, -100).") | |
| 24 ctx.beginPath(); | |
| 25 var p3 = new Path(); | |
| 26 p3.rect(0,0,100,100); | |
| 27 var p4 = new Path(); | |
| 28 p4.rect(0,100,100,100); | |
| 29 m.a = 1; m.b = 0; | |
| 30 m.c = 0; m.d = 1; | |
| 31 m.e = 100; m.f = -100; | |
| 32 p3.addPath(p4, m); | |
| 33 ctx.fillStyle = 'yellow'; | |
| 34 ctx.currentPath = p3; | |
| 35 ctx.fill(); | |
| 36 var imageData = ctx.getImageData(100, 0, 100, 100); | |
|
Justin Novosad
2014/02/19 16:38:28
no need for 'var' here. Same thing for following l
pals
2014/03/03 06:27:39
Done.
| |
| 37 var imgdata = imageData.data; | |
| 38 shouldBe("imgdata[4]", "255"); | |
| 39 shouldBe("imgdata[5]", "255"); | |
| 40 shouldBe("imgdata[6]", "0"); | |
| 41 shouldBe("imgdata[7]", "255"); | |
| 42 debug(""); | |
| 43 | |
| 44 debug("Test addPath() with non-invertible transform.") | |
| 45 ctx.beginPath(); | |
| 46 var p5 = new Path(); | |
| 47 p5.rect(0,0,100,100); | |
| 48 var p6 = new Path(); | |
| 49 p6.rect(100,100,100,100); | |
| 50 m.a = 0; m.b = 0; | |
| 51 m.c = 0; m.d = 0; | |
| 52 m.e = 0; m.f = 0; | |
| 53 p5.addPath(p6, m); | |
| 54 ctx.fillStyle = 'yellow'; | |
| 55 ctx.currentPath = p5; | |
| 56 ctx.fill(); | |
| 57 var imageData = ctx.getImageData(100, 100, 100, 100); | |
|
Justin Novosad
2014/02/19 16:38:28
Same here.
pals
2014/03/03 06:27:39
Done.
| |
| 58 var imgdata = imageData.data; | |
| 59 shouldNotBe("imgdata[4]", "255"); | |
| 60 shouldNotBe("imgdata[5]", "255"); | |
| 61 shouldBe("imgdata[6]", "0"); | |
| 62 shouldNotBe("imgdata[7]", "255"); | |
| 63 debug(""); | |
| 64 | |
| 65 debug("Test addPath() with transform as null.") | |
| 66 var p7 = new Path(); | |
| 67 p7.rect(0,0,100,100); | |
| 68 var p8 = new Path(); | |
| 69 shouldThrow("p7.addPath(p8, null)"); | |
| 70 debug(""); | |
| OLD | NEW |