2d.path.isPointInStroke.scaleddashes.html (1716B)
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>OffscreenCanvas test: 2d.path.isPointInStroke.scaleddashes</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 9 <h1>2d.path.isPointInStroke.scaleddashes</h1> 10 <p class="desc">isPointInStroke() should return correct results on dashed paths at high scale factors</p> 11 12 13 <script> 14 var t = async_test("isPointInStroke() should return correct results on dashed paths at high scale factors"); 15 var t_pass = t.done.bind(t); 16 var t_fail = t.step_func(function(reason) { 17 throw reason; 18 }); 19 t.step(function() { 20 21 var canvas = new OffscreenCanvas(100, 50); 22 var ctx = canvas.getContext('2d'); 23 24 var scale = 20; 25 ctx.setLineDash([10, 21.4159]); // dash from t=0 to t=10 along the circle 26 ctx.scale(scale, scale); 27 ctx.ellipse(6, 10, 5, 5, 0, 2*Math.PI, false); 28 ctx.stroke(); 29 30 // hit-test the beginning of the dash (t=0) 31 _assertSame(ctx.isPointInStroke(11*scale, 10*scale), true, "ctx.isPointInStroke(11*scale, 10*scale)", "true"); 32 // hit-test the middle of the dash (t=5) 33 _assertSame(ctx.isPointInStroke(8.70*scale, 14.21*scale), true, "ctx.isPointInStroke(8.70*scale, 14.21*scale)", "true"); 34 // hit-test the end of the dash (t=9.8) 35 _assertSame(ctx.isPointInStroke(4.10*scale, 14.63*scale), true, "ctx.isPointInStroke(4.10*scale, 14.63*scale)", "true"); 36 // hit-test past the end of the dash (t=10.2) 37 _assertSame(ctx.isPointInStroke(3.74*scale, 14.46*scale), false, "ctx.isPointInStroke(3.74*scale, 14.46*scale)", "false"); 38 t.done(); 39 40 }); 41 </script>