Tuesday, November 2, 2021

Canvas example. Scale function in javascript. To enlarge the size of Rectangle.

 <!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8" />

    <title>Canvas</title>

</head>

<body>

    <canvas id="myCanvas" width="300" height="150" style="border:1px solid#ffd800">

        Your browser does not support the HTML canvas tag.

    </canvas>


    <script>

        var c = document.getElementById("myCanvas");

        var ctx = c.getContext("2d");

        ctx.strokeRect(5, 5, 25, 15);

        ctx.scale(5, 5);

        ctx.strokeRect(5,5,25,15);

            </script>


</body>

</html>


Output:



No comments:

Post a Comment