OLD | NEW |
1 description("Test addPath() method."); | 1 description("Test addPath() method."); |
2 var canvas = document.createElement('canvas'); | 2 var canvas = document.createElement('canvas'); |
3 var ctx = canvas.getContext('2d'); | 3 var ctx = canvas.getContext('2d'); |
4 | 4 |
5 debug("Test addPath() with transform as identity matrix.") | 5 debug("Test addPath() with transform as identity matrix.") |
6 ctx.clearRect(0, 0, canvas.width, canvas.height); | 6 ctx.clearRect(0, 0, canvas.width, canvas.height); |
7 ctx.beginPath(); | 7 ctx.beginPath(); |
8 var p1 = new Path2D(); | 8 var p1 = new Path2D(); |
9 p1.rect(0,0,100,100); | 9 p1.rect(0,0,100,100); |
10 var p2 = new Path2D(); | 10 var p2 = new Path2D(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 debug(""); | 67 debug(""); |
68 | 68 |
69 debug("Test addPath() with transform as null or invalid type.") | 69 debug("Test addPath() with transform as null or invalid type.") |
70 ctx.clearRect(0, 0, canvas.width, canvas.height); | 70 ctx.clearRect(0, 0, canvas.width, canvas.height); |
71 ctx.beginPath(); | 71 ctx.beginPath(); |
72 var p7 = new Path2D(); | 72 var p7 = new Path2D(); |
73 p7.rect(0,0,100,100); | 73 p7.rect(0,0,100,100); |
74 var p8 = new Path2D(); | 74 var p8 = new Path2D(); |
75 p8.rect(100,100,100,100); | 75 p8.rect(100,100,100,100); |
76 p7.addPath(p8, null); | 76 p7.addPath(p8, null); |
77 p7.addPath(p8, []); | 77 shouldThrow("p7.addPath(p8, [])"); |
78 p7.addPath(p8, {}); | 78 shouldThrow("p7.addPath(p8, {})"); |
79 ctx.fillStyle = 'red'; | 79 ctx.fillStyle = 'red'; |
80 ctx.currentPath = p7; | 80 ctx.currentPath = p7; |
81 ctx.fill(); | 81 ctx.fill(); |
82 imageData = ctx.getImageData(100, 100, 100, 100); | 82 imageData = ctx.getImageData(100, 100, 100, 100); |
83 imgdata = imageData.data; | 83 imgdata = imageData.data; |
84 shouldBe("imgdata[4]", "255"); | 84 shouldBe("imgdata[4]", "255"); |
85 shouldBe("imgdata[5]", "0"); | 85 shouldBe("imgdata[5]", "0"); |
86 shouldBe("imgdata[6]", "0"); | 86 shouldBe("imgdata[6]", "0"); |
87 shouldBe("imgdata[7]", "255"); | 87 shouldBe("imgdata[7]", "255"); |
88 debug(""); | 88 debug(""); |
(...skipping 16 matching lines...) Expand all Loading... |
105 shouldBe("imgdata[3]", "255"); | 105 shouldBe("imgdata[3]", "255"); |
106 debug(""); | 106 debug(""); |
107 | 107 |
108 debug("Test addPath() with path as null and invalid type"); | 108 debug("Test addPath() with path as null and invalid type"); |
109 var p9 = new Path2D(); | 109 var p9 = new Path2D(); |
110 p9.rect(0,0,100,100); | 110 p9.rect(0,0,100,100); |
111 shouldThrow("p7.addPath(null, m)"); | 111 shouldThrow("p7.addPath(null, m)"); |
112 shouldThrow("p7.addPath([], m)"); | 112 shouldThrow("p7.addPath([], m)"); |
113 shouldThrow("p7.addPath({}, m)"); | 113 shouldThrow("p7.addPath({}, m)"); |
114 debug(""); | 114 debug(""); |
OLD | NEW |