| OLD | NEW | 
|---|
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <script src="../../resources/testharness.js"></script> | 
| 2 <html> | 2 <script src="../../resources/testharnessreport.js"></script> | 
| 3 <head> |  | 
| 4 <script src="../../resources/js-test.js"></script> |  | 
| 5 </head> |  | 
| 6 <body> | 3 <body> | 
| 7 <script src="script-tests/canvas-strokePath-alpha-shadow.js"></script> | 4 <script> | 
|  | 5 | 
|  | 6 // Ensure correct behavior of canvas with path stroke using a strokeStyle color 
    with alpha and a shadow. | 
|  | 7 | 
|  | 8 var canvas = document.createElement('canvas'); | 
|  | 9 document.body.appendChild(canvas); | 
|  | 10 canvas.setAttribute('width', '600'); | 
|  | 11 canvas.setAttribute('height', '1100'); | 
|  | 12 var ctx = canvas.getContext('2d'); | 
|  | 13 | 
|  | 14 ctx.save(); | 
|  | 15 ctx.strokeStyle = 'rgba(0, 0, 255, 0.5)'; | 
|  | 16 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)'; | 
|  | 17 ctx.shadowOffsetX = 250; | 
|  | 18 ctx.lineWidth = 50; | 
|  | 19 | 
|  | 20 function strokePath(x, y) { | 
|  | 21     ctx.beginPath(); | 
|  | 22     ctx.arc(x, y, 75, 0, Math.PI*2, true); | 
|  | 23     ctx.stroke(); | 
|  | 24 } | 
|  | 25 | 
|  | 26 // Alpha shadow. | 
|  | 27 ctx.shadowBlur = 0; | 
|  | 28 strokePath(150, 150); | 
|  | 29 | 
|  | 30 // Blurry shadow. | 
|  | 31 ctx.shadowBlur = 10; | 
|  | 32 strokePath(150, 400); | 
|  | 33 | 
|  | 34 ctx.rotate(Math.PI/2); | 
|  | 35 | 
|  | 36 // Rotated alpha shadow. | 
|  | 37 ctx.shadowBlur = 0; | 
|  | 38 strokePath(650, -150); | 
|  | 39 | 
|  | 40 // Rotated blurry shadow. | 
|  | 41 ctx.shadowBlur = 10; | 
|  | 42 strokePath(900, -150); | 
|  | 43 | 
|  | 44 ctx.restore(); | 
|  | 45 | 
|  | 46 var imageData, data; | 
|  | 47 ctx.fillStyle = 'black'; | 
|  | 48 | 
|  | 49 function testPixelAlphaShadow(x, y, color) | 
|  | 50 { | 
|  | 51     if (color.length == 4) { | 
|  | 52         assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color); | 
|  | 53     } else {    // we expect to have [r, g, b, a, alphaTolerance] | 
|  | 54         var data = ctx.getImageData(x, y, 1, 1).data; | 
|  | 55         assert_array_equals(data.slice(0,3), color.slice(0,3)); | 
|  | 56         assert_approx_equals(data[3], color[3], color[4]); | 
|  | 57     } | 
|  | 58     // Plot test point. | 
|  | 59     ctx.fillRect(x, y, 3, 3); | 
|  | 60 } | 
|  | 61 | 
|  | 62 var alphaTolerance = 15; | 
|  | 63 var testPixelAlphaShadowScenarios = [ | 
|  | 64     ['Verify alpha shadow 1', 400, 150, [0, 0, 0, 0]], | 
|  | 65     ['Verify alpha shadow 2', 400, 75, [255, 0, 0, 64, alphaTolerance]], | 
|  | 66     ['Verify alpha shadow 3', 400, 225, [255, 0, 0, 64, alphaTolerance]], | 
|  | 67     ['Verify alpha shadow 4', 325, 150, [255, 0, 0, 64, alphaTolerance]], | 
|  | 68     ['Verify alpha shadow 5', 475, 150, [255, 0, 0, 64, alphaTolerance]], | 
|  | 69 | 
|  | 70     ['Verify blurry shadow 1', 400, 400, [0, 0, 0, 0]], | 
|  | 71     ['Verify blurry shadow 2', 400, 300, [255, 0, 0, 31, alphaTolerance]], | 
|  | 72     ['Verify blurry shadow 3', 400, 500, [255, 0, 0, 31, alphaTolerance]], | 
|  | 73     ['Verify blurry shadow 4', 300, 400, [255, 0, 0, 31, alphaTolerance]], | 
|  | 74     ['Verify blurry shadow 5', 500, 400, [255, 0, 0, 31, alphaTolerance]], | 
|  | 75 | 
|  | 76     ['Verify rotated alpha shadow 1', 400, 650, [0, 0, 0, 0]], | 
|  | 77     ['Verify rotated alpha shadow 2', 400, 575, [255, 0, 0, 64, alphaTolerance]]
    , | 
|  | 78     ['Verify rotated alpha shadow 3', 400, 725, [255, 0, 0, 64, alphaTolerance]]
    , | 
|  | 79     ['Verify rotated alpha shadow 4', 325, 650, [255, 0, 0, 64, alphaTolerance]]
    , | 
|  | 80     ['Verify rotated alpha shadow 5', 475, 650, [255, 0, 0, 64, alphaTolerance]]
    , | 
|  | 81 | 
|  | 82     ['Verify rotated blurry shadow 1', 400, 900, [0, 0, 0, 0]], | 
|  | 83     ['Verify rotated blurry shadow 2', 400, 800, [255, 0, 0, 31, alphaTolerance]
    ], | 
|  | 84     ['Verify rotated blurry shadow 3', 400, 1000, [255, 0, 0, 31, alphaTolerance
    ]], | 
|  | 85     ['Verify rotated blurry shadow 2', 300, 900, [255, 0, 0, 31, alphaTolerance]
    ], | 
|  | 86     ['Verify rotated blurry shadow 2', 500, 900, [255, 0, 0, 31, alphaTolerance]
    ], | 
|  | 87 | 
|  | 88 ]; | 
|  | 89 | 
|  | 90 generate_tests(testPixelAlphaShadow, testPixelAlphaShadowScenarios); | 
|  | 91 | 
|  | 92 </script> | 
| 8 </body> | 93 </body> | 
| 9 </html> |  | 
| OLD | NEW | 
|---|