2d.gradient.radial.cone.shape2.html (1757B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>Canvas test: 2d.gradient.radial.cone.shape2</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> 9 <body class="show_output"> 10 11 <h1>2d.gradient.radial.cone.shape2</h1> 12 <p class="desc"></p> 13 14 15 <p class="output">Actual output:</p> 16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 17 <p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> 18 <ul id="d"></ul> 19 <script> 20 var t = async_test(""); 21 _addTest(function(canvas, ctx) { 22 23 var tol = 1; // tolerance to avoid antialiasing artifacts 24 25 ctx.fillStyle = '#0f0'; 26 ctx.fillRect(0, 0, 100, 50); 27 28 var g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); 29 g.addColorStop(0, '#f00'); 30 g.addColorStop(1, '#f00'); 31 ctx.fillStyle = g; 32 ctx.fillRect(0, 0, 100, 50); 33 34 ctx.fillStyle = '#0f0'; 35 ctx.beginPath(); 36 ctx.moveTo(30-tol, 40); 37 ctx.lineTo(110, -20-tol); 38 ctx.lineTo(110, 100+tol); 39 ctx.fill(); 40 41 _assertPixel(canvas, 1,1, 0,255,0,255); 42 _assertPixel(canvas, 50,1, 0,255,0,255); 43 _assertPixel(canvas, 98,1, 0,255,0,255); 44 _assertPixel(canvas, 1,25, 0,255,0,255); 45 _assertPixel(canvas, 50,25, 0,255,0,255); 46 _assertPixelApprox(canvas, 98,25, 0,255,0,255, 1); 47 _assertPixel(canvas, 1,48, 0,255,0,255); 48 _assertPixelApprox(canvas, 50,48, 0,255,0,255, 1); 49 _assertPixel(canvas, 98,48, 0,255,0,255); 50 51 }); 52 </script>