Html5 Canvas Transformation Algorithm - Finding object coordinates after applying transformation

前端 未结 2 681
名媛妹妹
名媛妹妹 2021-01-01 07:43

On html5 canvas I am drawing objects (rectangle, circle, etc...), these objects have transformation properties like scale, skew, rotation etc... These objects can be nested.

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 08:00

    Tom Larkworthy's answer is perfect, but with a minor typo. Correct formula to invert the matrix is:

    [  d/M  -c/M  (c*dy - d*dx)/M ]
    [ -b/M   a/M  (b*dx - a*dy)/M ]
    [   0     0          1        ]
    

提交回复
热议问题