1 description("Series of tests to ensure correct behaviour on transform of a pattern");
2 var canvas2 = document.createElement('canvas');
5 var ctx2 = canvas2.getContext('2d');
6 ctx2.fillStyle = '#0f0';
7 ctx2.fillRect(0, 0, 50, 50);
8 ctx2.fillRect(50, 50, 50, 50);
9 ctx2.fillStyle = '#f00';
10 ctx2.fillRect(50, 0, 50, 50);
11 ctx2.fillRect(0, 50, 50, 50);
13 var ctx = document.createElement('canvas').getContext('2d');
16 ctx.transform(2, 0, 0, 2, 0, 0);
17 var pattern = ctx.createPattern(canvas2, 'repeat');
18 ctx.fillStyle = pattern;
19 ctx.fillRect(0,0,100,100);
23 ctx.transform(0.5, 0, 0, 0.5, 0, 0);
24 pattern = ctx.createPattern(canvas2, 'repeat');
25 ctx.fillStyle = pattern;
26 ctx.fillRect(0,0,100,100);
29 var imageData = ctx.getImageData(26, 26, 74, 74);
30 var imgdata = imageData.data;
31 shouldBe("imgdata[4]", "0");
32 shouldBe("imgdata[5]", "255");
33 shouldBe("imgdata[6]", "0");
34 imageData = ctx.getImageData(25, 0, 25, 25);
35 imgdata = imageData.data;
36 shouldBe("imgdata[4]", "255");
37 shouldBe("imgdata[5]", "0");
38 shouldBe("imgdata[6]", "0");
39 imageData = ctx.getImageData(0, 0, 25, 25);
40 imgdata = imageData.data;
41 shouldBe("imgdata[4]", "0");
42 shouldBe("imgdata[5]", "255");
43 shouldBe("imgdata[6]", "0");