Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript rotate image canvas

function drawRotated(degrees){
    context.clearRect(0,0,canvas.width,canvas.height);
    context.save();
    context.translate(canvas.width/2,canvas.height/2);
    context.rotate(degrees*Math.PI/180);
    context.drawImage(image,-image.width/2,-image.width/2);
    context.restore();
}
 
PREVIOUS NEXT
Tagged: #javascript #rotate #image #canvas
ADD COMMENT
Topic
Name
2+8 =