I am trying to implement a transform bounding box in Paper.js, but it is not working properly yet.
Here is my code. As you can see, the path and the selection box do not seem to rotate around the same pivot, and both path get desynchronized after a while. Any idea why this happens?
I though about having both paths in a group, and transforming the group instead, but I had no time to try this yet.
What is the best way to implement this?
Every object's
pivot
point is at itsbounds.center
since you haven't explicitly declared another point. Because the bounding box of the transforming rectangle you've drawn offset by the rotation handle, you're transforming each pair of objects with respect to different centers. Try replacinginitSelectionRectangle(path)
with:Here's a working sketch