开发者

Raphael path centering

开发者 https://www.devze.com 2023-03-09 05:26 出处:网络
I have a canvas of size 480x480, with a grid of 8 rects by 8, each 60x60 (a chess board basically). I managed to succesfully import a svg (say a rook). I know how to scale and translate it to differe

I have a canvas of size 480x480, with a grid of 8 rects by 8, each 60x60 (a chess board basically).

I managed to succesfully import a svg (say a rook). I know how to scale and translate it to different places. I know how to drag'n'drop.

开发者_运维知识库The only thing I could not do is to force the path of the rook on the center of each square. When I drag the piece to a certain rect it should be automatically positioned to the center of the square it is dragged above.

I tried snapTo, but although some timid snapping tries are visible, the path still moves around easily.


I think I've solved it. It's all about the up function that ends a drag. Simply extract the drop coordinates and substract them from the desired position.

0

精彩评论

暂无评论...
验证码 换一张
取 消