https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 61d6fc4fc7e54a79e11b0fa2eab98cf7504e7cd0 authored by Anne van Kesteren on 03 April 2018, 13:43:56 UTC
fix earlier test; add two more per feedback
Tip revision: 61d6fc4
canvas_complexshapes_ispointInpath_001.htm
<!doctype HTML>
<html>
    <head>
        <title>HTML5 Canvas Test:  isPointInPath() unaffected by the current transformation matrix</title>
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
        <link rel="author" title="Microsoft" href="http://www.microsoft.com" />
        <link rel="help" href="http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath" />
        <meta name="assert" content="isPointInPath must check the point (x, y) as coordinates unaffected by the current transformation matrix." />
        <script type="text/javascript">
            async_test(function(t) {
              window.addEventListener("load", t.step_func_done(function runTest() {
                var canvas = document.getElementById("canvas1");
                var ctx = canvas.getContext("2d");

                // Create a path that is transformed by a translation transformation matrix.
                ctx.translate(100, 50);
                ctx.rect(0, 0, 100, 50);

                // Ensure that the coordinates passed to isPointInPath are unaffected by the current transformation matrix.
                assert_true(ctx.isPointInPath(125, 75), "isPointInPath(125, 75)");
                assert_false(ctx.isPointInPath(25, 25), "!isPointInPath(25, 25)");
              }));
            }, "isPointInPath unaffected by transformation matrix");
        </script>
    </head>
    <body>
        <p>Description: isPointInPath must check the point (x, y) as coordinates unaffected by the current transformation matrix.</p>
        <canvas id="canvas1" width="300" height="150">Browser does not support HTML5 Canvas.</canvas>
    </body>
</html>
back to top