Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Pen and Path tool improvements

Open Keavon opened this issue 1 year ago • 3 comments

All of this is explained/demonstrated in this detailed webcast: https://youtu.be/OmveqhzXJFg

Path tool

When dragging a handle:

  • Alt keeps the handles equidistant while pressed (instead of Shift in use now), and also creates a matching handle if the other is zero-length or not a cubic Bézier
  • Shift locks the handle angle to 15° increments
    • (shouldn't interfere with Shift-clicking-and-releasing-without-dragging to add/remove the handle to the selected points)
  • Ctrl locks the current angle of the handle
  • Tab swaps to dragging the opposite handle (native: teleports the cursor / web: enters pointer lock and draws a fake cursor at the new location)
  • Space shifts the anchor (and handles) while pressed
  • V toggles bent vs. colinear handles (instead of Alt in use now)

When dragging an anchor:

  • ~~Alt~~ Ctrl (updated since video was recorded) slides the anchor along its adjacent segment(s) while adjusting its handle(s) to best approximate the initial curvature
  • Alt (new since video was recorded) if held before the click-drag begins, converts the anchor's handles to smooth and drags the handle pair instead of the anchor using the "dragging a handle" mode above
  • Shift locks the drag to the nearer of the X or Y axes from its drag starting point (and should work whether or not the anchor is initially selected and whether or not the key is held before click-dragging)
    • (shouldn't interfere with Shift-clicking-and-releasing-without-dragging to add/remove the anchor to the selected points)

When a single handle is selected:

  • G already correctly grabs (translates) the point in space
  • R rotates about its anchor
  • S scales about its anchor

Pen tool

When placing a segment (pointer is up):

  • Backspace/Delete removes the current segment's handle (equivalent to clicking the current anchor)
  • G grabs (translates) the current segment's connected outgoing handle
  • R rotates the current segment's connected outgoing handle about its anchor
  • S scales the current segment's connected outgoing handle about its anchor

When dragging (pointer is down):

  • Alt stops keeping the handles equidistant while pressed, as long as they're currently colinear (otherwise it does nothing)
    • Exception: the reverse is the case (it keeps the handles equidistant while pressed) when the click-drag began with a single handle (either by click-dragging the current segment's connected anchor, click-dragging an endpoint of an existing not-yet-being-edited layer, or click-dragging the start point to close the shape) but Ctrl was pressed to keep
  • Ctrl locks the current angle of the handle (already implemented), but should also work to be colinear with the opposite handle if being dragged from an existing anchor point
  • Tab swaps to dragging the opposite handle (native: teleports the cursor / web: enters pointer lock and draws a fake cursor at the new location)
  • Space shifts the anchor (and handles) while pressed
  • V toggles bent vs. colinear handles (instead of the momentary Alt in use now)
  • If the current segment is closing the shape by connecting to its start point, the handle that's being dragged should be the closing handle, not a fake handle on the opposite side, and all the above shortcuts should work on that anchor/handle group spanning the start/end point (Tab will modify the shape of the first segment while the current/final segment is still in-progress)
  • All the above shortcuts should work with the "Bend Prev. Point" case where the current segment's connected anchor can be clicked to turn it sharp or click-dragged to bend its outgoing handle (turning its handles to not colinear), meaning V should be able to turn it back to colinear

Keavon avatar Jul 29 '24 11:07 Keavon

Aight, I start with it. Wish me luck

vdawg-git avatar Sep 07 '24 19:09 vdawg-git

Here are some more potential additions (coming from features I found useful in an abandoned vector graphics editor I had been working on years ago; originally listed here):

  • shift+G/R/S (or some other modifier) for setting handle mode (bent, colinear, and colinear+equidistant respectively) is a potential intuitive keybind option kinda following what regular g/r/s do;
  • that handle mode can be displayed visually as different icons on the point (square for bent, rectangle aligned to angle for colinear, and perhaps circle for equidistant, though that may get confusing with handles being circles; ellipse?)
  • allow both rotate and scale at the same time (maybe never useful but I still had this ¯\_(ツ)_/¯)
  • middle-mouse-dragging while holding an element should ignore the delta mouse movement during the movement (currently doing this in Graphite results in jumpiness)
  • another option for visual indicators r/g/s:
    • g: a line from the starting mouse position in the canvas to where it'd be dragged to
    • s: line from the anchor point through the current and original mouse position with different colors (i.e. the ratio of the color lengths is the ratio of scaling)
    • r: lines from the anchor to original & current mouse position, with an arc in between (very busy-looking, don't quite like it)

Some general actions:

  • cut a path into two, snapping to cutting on an existing point if near enough (potentially, if dragging, could cut into three segments)
  • join paths if two end-points are selected (incl. closing a path)
  • select all points linked to currently already selected ones

screen recording showing some of these in my editor

dzaima avatar Oct 16 '24 04:10 dzaima

Thank you for posting those here @dzaima! The feedback and ideas are very useful.

Keavon avatar Oct 16 '24 05:10 Keavon

Hey, I plan working on the remaining few things for the path tool. I will be traveling for the next few weeks so wont be able to start anytime soon. Although if anyone else wants to pick them up before im back feel free!

DaraghD avatar Oct 30 '24 20:10 DaraghD

@DaraghD hello again, I hope your travels were fruitful! Just wanted to see if you're interested in returning to some of the bullet points in this issue. In particular, the Pen tool ones aren't being attempted by anybody yet so those would be free to work on anytime you'd like, perhaps if you have some time over the holidays. Cheers!

Keavon avatar Dec 23 '24 23:12 Keavon

#2160 will add the following requested features-

  • [x] Shift locks the handle angle to 15° increments
    • [x] (shouldn't interfere with Shift-clicking handles for multi-selecting points such as handles)
  • [x] Ctrl locks the current angle of the handle

bakayu avatar Dec 28 '24 13:12 bakayu

completed #2180

0SlowPoke0 avatar Jan 15 '25 09:01 0SlowPoke0

completed #2295

4adex avatar Feb 17 '25 17:02 4adex

It would be good to have an operator for closing open paths - for both Pen tool and Freehand vector objects. This could be accessed from the Path Tool I suppose.

j-jasz avatar Mar 08 '25 13:03 j-jasz

@j-jasz good idea to add it to the UI. It's currently an undocumented shortcut, Ctrl+J, in the Path tool only. I'll think about how best to apply that to the other tools.

Keavon avatar Mar 08 '25 20:03 Keavon

Completed! Further tool improvements will be part of specific and more targeted issues, such as #2716. Thank you for the great efforts @0SlowPoke0 @4adex @DaraghD @bakayu.

Keavon avatar Jun 14 '25 20:06 Keavon