2d.path.isPointInPath.basic.html (2461B)
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>Canvas test: 2d.path.isPointInPath.basic</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 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> 9 <body class="show_output"> 10 11 <h1>2d.path.isPointInPath.basic</h1> 12 <p class="desc">Verify the winding rule in isPointInPath works for for rect path.</p> 13 14 15 <p class="output">Actual output:</p> 16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 17 18 <ul id="d"></ul> 19 <script> 20 var t = async_test("Verify the winding rule in isPointInPath works for for rect path."); 21 _addTest(function(canvas, ctx) { 22 23 canvas.width = 200; 24 canvas.height = 200; 25 26 // Testing default isPointInPath 27 ctx.beginPath(); 28 ctx.rect(0, 0, 100, 100); 29 ctx.rect(25, 25, 50, 50); 30 _assertSame(ctx.isPointInPath(50, 50), true, "ctx.isPointInPath(50, 50)", "true"); 31 _assertSame(ctx.isPointInPath(NaN, 50), false, "ctx.isPointInPath(NaN, 50)", "false"); 32 _assertSame(ctx.isPointInPath(50, NaN), false, "ctx.isPointInPath(50, NaN)", "false"); 33 34 // Testing nonzero isPointInPath 35 ctx.beginPath(); 36 ctx.rect(0, 0, 100, 100); 37 ctx.rect(25, 25, 50, 50); 38 _assertSame(ctx.isPointInPath(50, 50, 'nonzero'), true, "ctx.isPointInPath(50, 50, 'nonzero')", "true"); 39 40 // Testing evenodd isPointInPath 41 ctx.beginPath(); 42 ctx.rect(0, 0, 100, 100); 43 ctx.rect(25, 25, 50, 50); 44 _assertSame(ctx.isPointInPath(50, 50, 'evenodd'), false, "ctx.isPointInPath(50, 50, 'evenodd')", "false"); 45 46 // Testing extremely large scale 47 ctx.save(); 48 ctx.scale(Number.MAX_VALUE, Number.MAX_VALUE); 49 ctx.beginPath(); 50 ctx.rect(-10, -10, 20, 20); 51 _assertSame(ctx.isPointInPath(0, 0, 'nonzero'), true, "ctx.isPointInPath(0, 0, 'nonzero')", "true"); 52 _assertSame(ctx.isPointInPath(0, 0, 'evenodd'), true, "ctx.isPointInPath(0, 0, 'evenodd')", "true"); 53 ctx.restore(); 54 55 // Check with non-invertible ctm. 56 ctx.save(); 57 ctx.scale(0, 0); 58 ctx.beginPath(); 59 ctx.rect(-10, -10, 20, 20); 60 _assertSame(ctx.isPointInPath(0, 0, 'nonzero'), false, "ctx.isPointInPath(0, 0, 'nonzero')", "false"); 61 _assertSame(ctx.isPointInPath(0, 0, 'evenodd'), false, "ctx.isPointInPath(0, 0, 'evenodd')", "false"); 62 ctx.restore(); 63 64 }); 65 </script>