Canvas rotate from bottom center image angle?

后端 未结 4 1569
小蘑菇
小蘑菇 2020-12-08 03:23

How do you rotate an image with the canvas html5 element from the bottom center angle?


    
        test
         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 03:51

    I have used this, when I needed to rotate texts started from their specified point (center)?

    ctx.save(); 
    ctx.translate(x,y);
    ctx.rotate(degree*Math.PI/180);
    ctx.translate(-x,-y);   
    ctx.fillText(text,x,y); 
    ctx.stroke();   
    ctx.restore();
    

提交回复
热议问题