Skip to content

Allow edge shift to be a (start, end) pair - #179

Open
NeilGirdhar wants to merge 1 commit into
fletcher-package:mainfrom
NeilGirdhar:edge-shift-pair
Open

NeilGirdhar wants to merge 1 commit into
fletcher-package:mainfrom
NeilGirdhar:edge-shift-pair

Conversation

@NeilGirdhar

Copy link
Copy Markdown

Fletcher 0.5 accepted shift: (start, end) to shift each end of an edge separately. 0.6 made shift a whole-path offset and dropped the pair, so diagrams that fan several edges into or out of one node have no direct replacement after upgrading. This PR brings the pair back, built on 0.6's edge pipeline.

Behaviour

  • A single shift is unchanged: it still offsets the whole path.
  • A pair moves vertices before snapping, so shifted ends still meet node outlines.
    • Polylines (line edges with three or more vertices): the first leg moves by start, the last by end, and legs in between by amounts stepping evenly between the two. Each corner goes where its two offset legs meet, so every leg stays parallel to the original.
    • Other edges (straight, bend, corner, Bézier and custom kinds): each end vertex moves perpendicular to the path's direction at that end, and the kind redraws the path through the moved ends. An arc keeps its bend angle.
  • Equal values match a single shift on straight edges, arcs, corners and polylines, including with flipped axes. The new test draws each case over the single shift to show they coincide.
  • Numbers are multiples of the stroke thickness, the same as a single shift.
  • Loops, bows, and edges wrapping CeTZ objects reject a pair with an error that suggests a single shift. Pairs that aren't two values long are also rejected.

Difference from 0.5

On a polyline with three or more legs, 0.5 moved only the first and last legs. Here the legs in between move too, which is what makes equal values match the 0.6 single shift. Two-leg edges with right-angle corners come out the same as in 0.5.

Changes

  • paths.end-directions: the direction of travel at each end of a drawable.
  • edges.apply-end-shifts: moves the vertices, called from draw-edge before snapping.
  • get-edge-drawable moves out of apply-edge-snapping so draw-edge can share it.
  • The shift docstring documents the pair and adds an example.
  • New cases in tests/edge/shift.

Testing

  • tt run: all 51 tests pass, and the edge/shift reference image is updated.
  • The manual builds and shows the new example.
  • I didn't run the codebook spellcheck locally. "Polyline" already appears in the manual.

🤖 Generated with Claude Code

Fletcher 0.5 accepted `shift: (start, end)`, and 0.6 dropped it when
shift became a whole-path offset. Separate end shifts are the natural
way to fan several edges into or out of one node, so diagrams that
relied on them have no direct replacement in 0.6.

A pair moves the edge's vertices before snapping, so the shifted ends
still meet node outlines. Equal values give the same path as a single
shift for lines, arcs, corners, and polylines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NeilGirdhar

Copy link
Copy Markdown
Author

Yes, this is AI generated, and apologies for it! Just a starting point in case you're interested in reviving this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant