2d.path.isPointInStroke.scaleddashes.worker.js (1547B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.path.isPointInStroke.scaleddashes 3 // Description:isPointInStroke() should return correct results on dashed paths at high scale factors 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("isPointInStroke() should return correct results on dashed paths at high scale factors"); 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 scale = 20; 20 ctx.setLineDash([10, 21.4159]); // dash from t=0 to t=10 along the circle 21 ctx.scale(scale, scale); 22 ctx.ellipse(6, 10, 5, 5, 0, 2*Math.PI, false); 23 ctx.stroke(); 24 25 // hit-test the beginning of the dash (t=0) 26 _assertSame(ctx.isPointInStroke(11*scale, 10*scale), true, "ctx.isPointInStroke(11*scale, 10*scale)", "true"); 27 // hit-test the middle of the dash (t=5) 28 _assertSame(ctx.isPointInStroke(8.70*scale, 14.21*scale), true, "ctx.isPointInStroke(8.70*scale, 14.21*scale)", "true"); 29 // hit-test the end of the dash (t=9.8) 30 _assertSame(ctx.isPointInStroke(4.10*scale, 14.63*scale), true, "ctx.isPointInStroke(4.10*scale, 14.63*scale)", "true"); 31 // hit-test past the end of the dash (t=10.2) 32 _assertSame(ctx.isPointInStroke(3.74*scale, 14.46*scale), false, "ctx.isPointInStroke(3.74*scale, 14.46*scale)", "false"); 33 t.done(); 34 }); 35 done();