javascript rotate image canvas

Solutions on MaxInterview for javascript rotate image canvas by the best coders in the world

showing results for - "javascript rotate image canvas"
Maria
28 Aug 2020
1function drawRotated(degrees){
2    context.clearRect(0,0,canvas.width,canvas.height);
3    context.save();
4    context.translate(canvas.width/2,canvas.height/2);
5    context.rotate(degrees*Math.PI/180);
6    context.drawImage(image,-image.width/2,-image.width/2);
7    context.restore();
8}