1 description("Series of tests to ensure correct results of the winding rule.");
4 var tmpimg
= document
.createElement('canvas');
7 ctx
= tmpimg
.getContext('2d');
9 // Create the image for blending test with images.
10 var img
= document
.createElement('canvas');
13 var imgCtx
= img
.getContext('2d');
15 function pixelDataAtPoint()
17 return ctx
.getImageData(50, 50, 1, 1).data
;
20 function checkResult(expectedColors
, sigma
) {
21 for (var i
= 0; i
< 4; i
++)
22 shouldBeCloseTo("pixelDataAtPoint()[" + i
+ "]", expectedColors
[i
], sigma
);
26 function prepareTestScenario() {
27 debug('Testing default clip');
28 ctx
.fillStyle
= 'rgb(255,0,0)';
29 ctx
.fillRect(0, 0, 100, 100);
30 ctx
.fillStyle
= 'rgb(0,255,0)';
32 ctx
.rect(0, 0, 100, 100);
33 ctx
.rect(25, 25, 50, 50);
36 ctx
.fillRect(0, 0, 100, 100);
37 checkResult([0, 255, 0, 255], 5);
40 debug('Testing nonzero clip');
41 ctx
.fillStyle
= 'rgb(255,0,0)';
42 ctx
.fillRect(0, 0, 100, 100);
43 ctx
.fillStyle
= 'rgb(0,255,0)';
45 ctx
.rect(0, 0, 100, 100);
46 ctx
.rect(25, 25, 50, 50);
49 ctx
.fillRect(0, 0, 100, 100);
50 checkResult([0, 255, 0, 255], 5);
53 debug('Testing evenodd clip');
54 ctx
.fillStyle
= 'rgb(255,0,0)';
55 ctx
.fillRect(0, 0, 100, 100);
56 ctx
.fillStyle
= 'rgb(0,255,0)';
58 ctx
.rect(0, 0, 100, 100);
59 ctx
.rect(25, 25, 50, 50);
62 ctx
.fillRect(0, 0, 100, 100);
63 checkResult([255, 0, 0, 255], 5);
68 // Run test and allow variation of results.
69 prepareTestScenario();