2d.gradient.radial.cone.shape1.worker.js (1384B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.gradient.radial.cone.shape1 3 // Description: 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test(""); 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 var tol = 1; // tolerance to avoid antialiasing artifacts 20 21 ctx.fillStyle = '#0f0'; 22 ctx.fillRect(0, 0, 100, 50); 23 24 ctx.fillStyle = '#f00'; 25 ctx.beginPath(); 26 ctx.moveTo(30+tol, 40); 27 ctx.lineTo(110, -20+tol); 28 ctx.lineTo(110, 100-tol); 29 ctx.fill(); 30 31 var g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); 32 g.addColorStop(0, '#0f0'); 33 g.addColorStop(1, '#0f0'); 34 ctx.fillStyle = g; 35 ctx.fillRect(0, 0, 100, 50); 36 37 _assertPixel(canvas, 1,1, 0,255,0,255); 38 _assertPixel(canvas, 50,1, 0,255,0,255); 39 _assertPixel(canvas, 98,1, 0,255,0,255); 40 _assertPixel(canvas, 1,25, 0,255,0,255); 41 _assertPixel(canvas, 50,25, 0,255,0,255); 42 _assertPixelApprox(canvas, 98,25, 0,255,0,255, 1); 43 _assertPixel(canvas, 1,48, 0,255,0,255); 44 _assertPixelApprox(canvas, 50,48, 0,255,0,255, 1); 45 _assertPixel(canvas, 98,48, 0,255,0,255); 46 t.done(); 47 }); 48 done();