All Articles

Week 5 - OnCanvas Alignment Guides

Image

Improving Distribution Snapping

I added a very rough implementation of distribution snapping last week and this week I tried to improve the code. Implementing distribution snapping has been a lot more challenging than alignment snapping and I am glad it is coming along so well. This week I was also able to add Bidirectional distribution snapping and also imporve the existing algorithm. Up until last week the number of objects that were considered to be equidistant was not fixed and it varied each time you moved an object. Now this should be much more consistent, though in some cases there may be a little difference. Overall distribution snapping algorithm now runs faster than it did before.

Snap indicators also have been updated to take into account more snap possibilities. I spent a lot of time this week cleaning up the code and that must help readability a lot.

Image

Next Up

Distribution snapping, in its current form does not take multiple snap possibilities into account for now. I hope to improve the algorithm to work more like it does on Figma.

A comparison between Inkscape and Figma’s distribution snapping

Figma Inkscape
Image Image