+ 4
a
how to rotate a canvas
2 Réponses
+ 1
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rotate(20*Math.PI/180);
ctx.fillRect(50,20,100,50);
+ 1
you can use javascript for this purpose. Simply set id attribute on canvas and rotate it with js.
index.html:
<canvas id="mCanv" width="300" height="150"></canvas>
code.js:
var cv=document.getElementById("mCanv"),
ctx=cv.getContext("2d");
ctx.rotate(20*Math.PI / 180);
ctx.fillRect(50, 10, 100, 50);
and so one, like you want🙂