| OLD | NEW |
| (Empty) |
| 1 description("Series of tests to ensure correct results of the winding rule."); | |
| 2 | |
| 3 | |
| 4 var tmpimg = document.createElement('canvas'); | |
| 5 tmpimg.width = 200; | |
| 6 tmpimg.height = 200; | |
| 7 ctx = tmpimg.getContext('2d'); | |
| 8 | |
| 9 // Create the image for blending test with images. | |
| 10 var img = document.createElement('canvas'); | |
| 11 img.width = 100; | |
| 12 img.height = 100; | |
| 13 var imgCtx = img.getContext('2d'); | |
| 14 | |
| 15 function pixelDataAtPoint() | |
| 16 { | |
| 17 return ctx.getImageData(50, 50, 1, 1).data; | |
| 18 } | |
| 19 | |
| 20 function checkResult(expectedColors, sigma) { | |
| 21 for (var i = 0; i < 4; i++) | |
| 22 shouldBeCloseTo("pixelDataAtPoint()[" + i + "]", expectedColors[i],
sigma); | |
| 23 } | |
| 24 | |
| 25 // Execute test. | |
| 26 function prepareTestScenario() { | |
| 27 debug('Testing default fill'); | |
| 28 ctx.fillStyle = 'rgb(255,0,0)'; | |
| 29 ctx.beginPath(); | |
| 30 ctx.fillRect(0, 0, 100, 100); | |
| 31 ctx.fillStyle = 'rgb(0,255,0)'; | |
| 32 ctx.beginPath(); | |
| 33 ctx.rect(0, 0, 100, 100); | |
| 34 ctx.rect(25, 25, 50, 50); | |
| 35 ctx.fill(); | |
| 36 checkResult([0, 255, 0, 255], 5); | |
| 37 debug(''); | |
| 38 | |
| 39 debug('Testing nonzero fill'); | |
| 40 ctx.fillStyle = 'rgb(255,0,0)'; | |
| 41 ctx.beginPath(); | |
| 42 ctx.fillRect(0, 0, 100, 100); | |
| 43 ctx.fillStyle = 'rgb(0,255,0)'; | |
| 44 ctx.beginPath(); | |
| 45 ctx.rect(0, 0, 100, 100); | |
| 46 ctx.rect(25, 25, 50, 50); | |
| 47 ctx.fill('nonzero'); | |
| 48 checkResult([0, 255, 0, 255], 5); | |
| 49 debug(''); | |
| 50 | |
| 51 debug('Testing evenodd fill'); | |
| 52 ctx.fillStyle = 'rgb(255,0,0)'; | |
| 53 ctx.beginPath(); | |
| 54 ctx.fillRect(0, 0, 100, 100); | |
| 55 ctx.fillStyle = 'rgb(0,255,0)'; | |
| 56 ctx.beginPath(); | |
| 57 ctx.rect(0, 0, 100, 100); | |
| 58 ctx.rect(25, 25, 50, 50); | |
| 59 ctx.fill('evenodd'); | |
| 60 checkResult([255, 0, 0, 255], 5); | |
| 61 debug(''); | |
| 62 | |
| 63 } | |
| 64 | |
| 65 // Run test and allow variation of results. | |
| 66 prepareTestScenario(); | |
| OLD | NEW |