OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> |
| 3 <title>OffscreenCanvas test: 2d.gradient.radial.cone.shape2</title> |
| 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="/common/canvas-tests.js"></script> |
| 7 |
| 8 <h1>2d.gradient.radial.cone.shape2</h1> |
| 9 <p class="desc"></p> |
| 10 |
| 11 |
| 12 <script> |
| 13 var t = async_test(""); |
| 14 t.step(function() { |
| 15 |
| 16 var offscreenCanvas = new OffscreenCanvas(100, 50); |
| 17 var ctx = offscreenCanvas.getContext('2d'); |
| 18 |
| 19 var tol = 1; // tolerance to avoid antialiasing artifacts |
| 20 ctx.fillStyle = '#0f0'; |
| 21 ctx.fillRect(0, 0, 100, 50); |
| 22 var g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); |
| 23 g.addColorStop(0, '#f00'); |
| 24 g.addColorStop(1, '#f00'); |
| 25 ctx.fillStyle = g; |
| 26 ctx.fillRect(0, 0, 100, 50); |
| 27 ctx.fillStyle = '#0f0'; |
| 28 ctx.beginPath(); |
| 29 ctx.moveTo(30-tol, 40); |
| 30 ctx.lineTo(110, -20-tol); |
| 31 ctx.lineTo(110, 100+tol); |
| 32 ctx.fill(); |
| 33 _assertPixel(offscreenCanvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255"); |
| 34 _assertPixel(offscreenCanvas, 50,1, 0,255,0,255, "50,1", "0,255,0,255"); |
| 35 _assertPixel(offscreenCanvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255"); |
| 36 _assertPixel(offscreenCanvas, 1,25, 0,255,0,255, "1,25", "0,255,0,255"); |
| 37 _assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); |
| 38 _assertPixel(offscreenCanvas, 98,25, 0,255,0,255, "98,25", "0,255,0,255"); |
| 39 _assertPixel(offscreenCanvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255"); |
| 40 _assertPixel(offscreenCanvas, 50,48, 0,255,0,255, "50,48", "0,255,0,255"); |
| 41 _assertPixel(offscreenCanvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255"); |
| 42 |
| 43 t.done(); |
| 44 |
| 45 }); |
| 46 </script> |
OLD | NEW |