Canvas rotate from bottom center image angle?

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

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


    
        test
         


        
4条回答
  •  被撕碎了的回忆
    2020-12-08 04:03

    The correct answer is, of course, Vincent's one.
    I fumbled a bit with this rotation/translation thing, and I think my little experiments could be interesting to show:

    
      
        test
        
      
      
        
      
    
    

    My stumbling issue was that positioning the rotated figure is hard, because it is along the rotated axis: either we have to do some trigo math to paint at the primitive origin, or we have to draw on a secondary hidden canvas and then paint it on the target one.
    Unless somebody else has a better idea?

提交回复
热议问题