How to use rotate() to rectangle in JavaScript

1 Answer

0 votes
<canvas id="canvas"></canvas>
<script type="text/JavaScript">   
           
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

// void ctx.rotate(angle);
// ctx.fillRect(x,y,width,height);

ctx.rotate(45 * Math.PI / 180);
ctx.fillRect(70, 30, 120, 40);

</script>

 



answered May 27, 2016 by avibootz
...