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 fill');
28 ctx.fillStyle = 'rgb(255,0,0)';
30 ctx.fillRect(0, 0, 100, 100);
31 ctx.fillStyle = 'rgb(0,255,0)';
33 ctx.rect(0, 0, 100, 100);
34 ctx.rect(25, 25, 50, 50);
36 checkResult([0, 255, 0, 255], 5);
39 debug('Testing nonzero fill');
40 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);
48 checkResult([0, 255, 0, 255], 5);
51 debug('Testing evenodd fill');
52 ctx.fillStyle = 'rgb(255,0,0)';
54 ctx.fillRect(0, 0, 100, 100);
55 ctx.fillStyle = 'rgb(0,255,0)';
57 ctx.rect(0, 0, 100, 100);
58 ctx.rect(25, 25, 50, 50);
60 checkResult([255, 0, 0, 255], 5);
65 // Run test and allow variation of results.
66 prepareTestScenario();