2d.path.isPointInPath.winding.html (1838B)
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.isPointInPath.winding</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.isPointInPath.winding</h1> 10 <p class="desc">isPointInPath() uses the non-zero winding number rule</p> 11 12 13 <script> 14 var t = async_test("isPointInPath() uses the non-zero winding number rule"); 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 // Create a square ring, using opposite windings to make a hole in the centre 25 ctx.moveTo(0, 0); 26 ctx.lineTo(50, 0); 27 ctx.lineTo(50, 50); 28 ctx.lineTo(0, 50); 29 ctx.lineTo(0, 0); 30 ctx.lineTo(10, 10); 31 ctx.lineTo(10, 40); 32 ctx.lineTo(40, 40); 33 ctx.lineTo(40, 10); 34 ctx.lineTo(10, 10); 35 36 _assertSame(ctx.isPointInPath(5, 5), true, "ctx.isPointInPath(5, 5)", "true"); 37 _assertSame(ctx.isPointInPath(25, 5), true, "ctx.isPointInPath(25, 5)", "true"); 38 _assertSame(ctx.isPointInPath(45, 5), true, "ctx.isPointInPath(45, 5)", "true"); 39 _assertSame(ctx.isPointInPath(5, 25), true, "ctx.isPointInPath(5, 25)", "true"); 40 _assertSame(ctx.isPointInPath(25, 25), false, "ctx.isPointInPath(25, 25)", "false"); 41 _assertSame(ctx.isPointInPath(45, 25), true, "ctx.isPointInPath(45, 25)", "true"); 42 _assertSame(ctx.isPointInPath(5, 45), true, "ctx.isPointInPath(5, 45)", "true"); 43 _assertSame(ctx.isPointInPath(25, 45), true, "ctx.isPointInPath(25, 45)", "true"); 44 _assertSame(ctx.isPointInPath(45, 45), true, "ctx.isPointInPath(45, 45)", "true"); 45 t.done(); 46 47 }); 48 </script>