How to get the canvas-relative position of an object that is in a group?

前端 未结 4 1953
野的像风
野的像风 2020-11-30 11:36

Normally an object\'s position relative to the canvas can be gotten from it\'s .left and .top attributes, but these become relative to the group if

4条回答
  •  暖寄归人
    2020-11-30 11:49

    just as a complement to Swapnil Jain's answer the same goes for the top attribute.

    So:

    absoluteLeft = rect.left + rect.group.left - rect.group.width / 2
    absoluteTop = rect.top + rect.group.top - rect.group.height / 2
    

提交回复
热议问题