I have implemented snapping for graphite, a work in progress vector editor written in the Rust programming language with Web Assembly. Snapping is quite an important feature of a vector editor as it allows users much more precision when drawing shapes and moving shapes around. One of the main challenges I had was caching the snap targets in a sensible place as TrueDoctor requested the tools did not have mutable access to the document so that they could be multi-threaded later. I also implemented the toggle functionality with the magnet option in the toolbar at the top. The functionality is available on the master branch build of graphite at editor.graphite.design/ The code changes are available at github.com/GraphiteEditor/Graphite/pull/386/files
I am doing lots of projects every projects all the time and I can't put them all on the website so I've made a blog.