1 description("Ensure correct behavior of canvas with path stroke with cap and join");
3 var canvas = document.createElement('canvas');
4 document.body.appendChild(canvas);
5 canvas.setAttribute('width', '700');
6 canvas.setAttribute('height', '200');
7 var ctx = canvas.getContext('2d');
12 ctx.fillStyle="rgba(255, 255, 255, 1.0)";
13 ctx.fillRect(0, 0, 700, 200);
15 ctx.strokeStyle="rgba(0, 0, 0, 1.0)";
16 ctx.lineJoin = "miter";
17 ctx.lineCap = "round";
48 ctx.lineJoin = "bevel";
49 ctx.lineCap = "square";
51 ctx.translate(200, 0);
80 ctx.lineJoin = "round";
83 ctx.translate(200, 0);
114 // Verify Join : miter, Cap : round.
115 imageData = ctx.getImageData(30, 51, 1, 1);
116 data = imageData.data;
117 shouldBe('data[0]', '0');
119 imageData = ctx.getImageData(30, 49, 1, 1);
120 data = imageData.data;
121 shouldBe('data[0]', '255');
123 imageData = ctx.getImageData(14, 154, 1, 1);
124 data = imageData.data;
125 shouldBe('data[0]', '0');
127 imageData = ctx.getImageData(14, 157, 1, 1);
128 data = imageData.data;
129 shouldBe('data[0]', '255');
131 imageData = ctx.getImageData(89, 22, 1, 1);
132 data = imageData.data;
133 shouldBe('data[0]', '0');
135 imageData = ctx.getImageData(89, 12, 1, 1);
136 data = imageData.data;
137 shouldBe('data[0]', '255');
139 imageData = ctx.getImageData(184, 29, 1, 1);
140 data = imageData.data;
141 shouldBe('data[0]', '0');
143 imageData = ctx.getImageData(180, 27, 1, 1);
144 data = imageData.data;
145 shouldBe('data[0]', '255');
147 imageData = ctx.getImageData(132, 152, 1, 1);
148 data = imageData.data;
149 shouldBe('data[0]', '0');
151 imageData = ctx.getImageData(130, 157, 1, 1);
152 data = imageData.data;
153 shouldBe('data[0]', '255');
155 // Verify Join : bevel, Cap : square.
156 imageData = ctx.getImageData(202, 154, 1, 1);
157 data = imageData.data;
158 shouldBe('data[0]', '0');
160 imageData = ctx.getImageData(201, 150, 1, 1);
161 data = imageData.data;
162 shouldBe('data[0]', '255');
164 imageData = ctx.getImageData(228, 52, 1, 1);
165 data = imageData.data;
166 shouldBe('data[0]', '0');
168 imageData = ctx.getImageData(225, 48, 1, 1);
169 data = imageData.data;
170 shouldBe('data[0]', '255');
172 imageData = ctx.getImageData(316, 154, 1, 1);
173 data = imageData.data;
174 shouldBe('data[0]', '0');
176 imageData = ctx.getImageData(316, 157, 1, 1);
177 data = imageData.data;
178 shouldBe('data[0]', '255');
180 imageData = ctx.getImageData(289, 52, 1, 1);
181 data = imageData.data;
182 shouldBe('data[0]', '0');
184 imageData = ctx.getImageData(289, 48, 1, 1);
185 data = imageData.data;
186 shouldBe('data[0]', '255');
188 imageData = ctx.getImageData(372, 58, 1, 1);
189 data = imageData.data;
190 shouldBe('data[0]', '0');
192 imageData = ctx.getImageData(373, 54, 1, 1);
193 data = imageData.data;
194 shouldBe('data[0]', '255');
196 imageData = ctx.getImageData(380, 159, 1, 1);
197 data = imageData.data;
198 shouldBe('data[0]', '0');
200 imageData = ctx.getImageData(383, 162, 1, 1);
201 data = imageData.data;
202 shouldBe('data[0]', '255');
204 // Verify Join : round, Cap : butt.
205 imageData = ctx.getImageData(405, 147, 1, 1);
206 data = imageData.data;
207 shouldBe('data[0]', '0');
209 imageData = ctx.getImageData(405, 151, 1, 1);
210 data = imageData.data;
211 shouldBe('data[0]', '255');
213 imageData = ctx.getImageData(429, 46, 1, 1);
214 data = imageData.data;
215 shouldBe('data[0]', '0');
217 imageData = ctx.getImageData(429, 43, 1, 1);
218 data = imageData.data;
219 shouldBe('data[0]', '255');
221 imageData = ctx.getImageData(464, 146, 1, 1);
222 data = imageData.data;
223 shouldBe('data[0]', '0');
225 imageData = ctx.getImageData(464, 150, 1, 1);
226 data = imageData.data;
227 shouldBe('data[0]', '255');
229 imageData = ctx.getImageData(489, 46, 1, 1);
230 data = imageData.data;
231 shouldBe('data[0]', '0');
233 imageData = ctx.getImageData(489, 43, 1, 1);
234 data = imageData.data;
235 shouldBe('data[0]', '255');
237 imageData = ctx.getImageData(534, 151, 1, 1);
238 data = imageData.data;
239 shouldBe('data[0]', '0');
241 imageData = ctx.getImageData(531, 153, 1, 1);
242 data = imageData.data;
243 shouldBe('data[0]', '255');
245 imageData = ctx.getImageData(579, 52, 1, 1);
246 data = imageData.data;
247 shouldBe('data[0]', '0');
249 imageData = ctx.getImageData(579, 48, 1, 1);
250 data = imageData.data;
251 shouldBe('data[0]', '255');