Code
<!DOCTYPE html>
<html>
    <head>
        <title>wikitechy-rotate()method in canvas</title>
    </head>
    <body>
        <h1>wikitechy-rotate()method in canvas</h1>
        <canvas id="wikitechyCanvas" width="300" height="150"
                style="border:1px solid #d3d3d3;"
>

        </canvas>
        <script>
            var canvas = document.getElementById("wikitechyCanvas");
            var context = canvas.getContext("2d");
            context.rotate(20 * Math.PI / 180);
            context.fillRect(50, 20, 100, 50);
        
</script>
    </body>
</html>


Result