+ 4

a

how to rotate a canvas

19th Jul 2017, 6:58 AM
anita dala
anita dala - avatar
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);
19th Jul 2017, 7:17 AM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 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🙂
19th Jul 2017, 7:16 AM
Вап