2d.gradient.conic.positive.rotation.worker.js (1016B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.gradient.conic.positive.rotation 3 // Description:Conic gradient with positive rotation 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("Conic gradient with positive rotation"); 10 var t_pass = t.done.bind(t); 11 var t_fail = t.step_func(function(reason) { 12 throw reason; 13 }); 14 t.step(function() { 15 16 var canvas = new OffscreenCanvas(100, 50); 17 var ctx = canvas.getContext('2d'); 18 19 const g = ctx.createConicGradient(3*Math.PI/2, 50, 25); 20 // It's red in the upper right region and green on the lower left region 21 g.addColorStop(0, "#f00"); 22 g.addColorStop(0.25, "#0f0"); 23 g.addColorStop(0.50, "#0f0"); 24 g.addColorStop(0.75, "#f00"); 25 ctx.fillStyle = g; 26 ctx.fillRect(0, 0, 100, 50); 27 _assertPixelApprox(canvas, 25,15, 255,0,0,255, 3); 28 _assertPixelApprox(canvas, 75,40, 0,255,0,255, 3); 29 t.done(); 30 }); 31 done();