CaseLeaf

Handbook / Working on a path after you have drawn it

Working on a path after you have drawn it

A line, a polygon, a polyline and a freehand stroke are all paths: a sequence of points with segments between them. Once one is on the page you can change its shape rather than draw it again.

Everything here is on the path's context menu. What you get depends on where you pressed: on a node, or along a segment between two nodes. Pressing in a different spot offers different things.

Joining two paths, and closing a shape

Drag one end of a path near another end and they catch: the end snaps exactly onto the other, and the two paths become one.

The join works whichever way you approach it. Dragging an existing end over another end offers the snap, and so does starting a new line or stroke on top of an existing end. The second case is easy to miss: you are not holding the old end, you are placing the first point of a new path on top of it. Neither direction cares what kind of path is at either end. A line brought to a stroke's end, or a stroke started on a line's end, catches the same way a line catches on a line.

The reach is generous on purpose: twenty screen points, and never less than six points on the page. Both limits are needed. A fixed screen distance would shrink to nothing as you zoom in, and zooming in is exactly what you do to place something precisely.

A join takes priority over an alignment guide. When a guide and a join are both within reach, they disagree by a fraction of a point. Taking the guide would leave two segments that look joined but are measurably apart.

Bring a path back to its own starting point and it closes. Several pieces meeting end to end become one shape, and so does a single stroke brought back to where it began. A closed shape can be filled, since four lines that merely touch have no inside to fill. Closing produces a real polygon instead of a group, matching how every other PDF reader treats it.

The closed shape takes the colour, width and fill of the armed swatch, like any newly drawn shape. It is a single undo: to you, closing a shape is one action.

Changing the shape

Press on the path, anywhere along it, and the menu offers four things about that place:

  • Add Node Here: puts a point where you pressed.
  • Break Here: cuts the path in two at that place.
  • Smooth Segment: makes that stretch bend.
  • Straighten Segment: makes it run straight again.

A stroke is a path too. All four are offered on freehand exactly as on a drawn line: a squiggle can be broken, joined and closed like anything else.

A polygon or polyline has its own menu, nearly the same: Add Node Here, Break Path Here, Curve Segment and Smooth Segment.

Each segment can be bent on its own with Curve Segment. On a segment already bent, that entry becomes Straighten Segment, so the same place in the menu offers whichever of the two you can do. This is also the difference between curving a segment and smoothing it: smoothing changes how the path passes through its points, curving changes one piece of it between two points.

Curve Segment does not bend anything by itself. It places the segment's two handles a third and two thirds along it, a position that draws a straight line. The segment becomes bendable, but the shape you drew does not move: the page looks the same, and the status line confirms this side can be bent now. Drag the segment, or its handles, to bend it.

On a freehand stroke the menu offers Straighten Segment and Smooth Segment, but no Curve Segment. A stroke's span is already bendable, so Smooth Segment bends it and Straighten Segment takes the bend out. A third entry to make it bendable would have nothing to do, since it already is.

Press on a node itself and the menu is about that node instead:

  • Remove Node: takes the point out.
  • Smooth Node: the path bends through it.
  • Sharpen Node: it becomes a corner. Offered on a stroke's knot; a polygon's corner is already a corner.
  • Break Here: still offered, since cutting at a node is a sensible thing to want.

The press has to land within about six points of the node. If you get the segment menu when you wanted the node menu, you were not quite on it. Zoom in and the six points become a wider target on screen.

Tangent handles

A curve's bend is normally derived: each knot's tangent comes from where its neighbours sit, so an ordinary curve needs nothing stored at all.

Pressing a knot shows its two tangent handles, the levers on either side of it that bend the curve there. This is not a new gesture: choosing a node already means something, and this is what it means. Press anywhere else and the handles go away, so a curve never carries handles for a knot nobody is working on. Only one knot's pair is shown at a time.

The handles are drawn green, with a rod to each one. An anchor is a point the shape passes through; a tangent handle bends the side beside it. Using the same white dot for both would make it hard to tell which one you are dragging. The rod runs from the knot to its handle, so it is clear which knot a green dot belongs to.

A polygon's corners can be bent the same way, but not by pressing the corner alone. Choose Curve Segment on the side you want to bend, and its tangent handles appear; from then on they are dragged like a curve's.

A hand-set tangent wins over the derived one, for that side only. Bending one knot leaves its neighbours' curves exactly as they were: the edit stays local rather than stiffening the rest of the line. What you have bent is kept separately, so a curve nobody has touched carries none of this at all. Opening a curve from another reader, or one drawn before tangent handles existed, still derives every knot exactly as before.

Curved and straight strokes

A freehand stroke is drawn as the smooth curve it looked like while you drew it: points thinned to the ones that carry the shape, then joined by a curve through them. The file format cannot hold this directly. PDF's ink annotation stores only the points the pointer passed through, nothing about what should join them, and a reader is free to draw whatever it likes between them. This application draws the curve into the mark's own appearance and separately marks the stroke as meant to curve, so that opening the file again puts the curve back instead of the straight lines PDFKit would otherwise join those points with.

Straightening a node or a span tells the application this is not a curve here. Sharpen Node and Straighten Segment do not just flatten what is on screen: they remove the meant to curve mark for the knot or span you touched, so the straight line you asked for is still straight the next time the document is opened. Without that, a stroke straightened by hand would come back bent on reopening, since reloading restores the curve for anything still marked as one. Smooth Segment restores the mark instead of writing numbers to reproduce the bend, so a later edit to a neighbouring knot does not find a span frozen where it was.

Only a stroke this application drew is treated this way. An ink mark from another program may be a deliberate polyline, such as a technical drawing or a signature captured as segments, and curving it would be an invention nobody asked for.

Watch: a short video for this page is still to come.


Shapes and freehand · Contents