Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Adding points to shapes with the Path Tool

Open otdavies opened this issue 3 years ago • 0 comments

The path tool needs the ability to create points.

When creating points we want to maintain the curve / shape of the Bezier, this resource should help: https://pomax.github.io/bezierinfo/

When deleting points we want to differentiate between dissolving and deleting entirely. Dissolving keeps the connections to nearby points, deleting deletes the edges joining them and the point. A modifier key might work here. If one had to be chosen to be implemented, dissolve is preferred.

The files to look at when working on this are: shape_editor.rs, vector_shape.rs, vector_anchor.rs

Things to keep in mind: Remember to cleanup the overlays by calling "remove_overlay(..)" or similar when you delete an anchor.

Additional context: The path tools life cycle is a little strange, whenever you "select" a shape it recreates the VectorShape for that shape. You may need to recreate the VectorShape each time you create or delete a point currently. The path tool does not support editing the VectorShape without recreating it, for example update_shape assumes the shape is of the same number of PathElements. If VectorShape needs to be more dynamic, you'll need to do some refactoring. I'd start with the constructor and break out how it loads in the shape. Obviously recreating the VectorShape each selection is a stop-gap, not ideal.

See Pen tool for some "hacks" to get around these limitations for now.

otdavies avatar Feb 12 '22 20:02 otdavies