Skip to content

Draw: Ink to Shape recognises arrows - #1520

Merged
echelon merged 6 commits into
storytold:mainfrom
dkhlapov:feat-ink-to-shape-arrows
Oct 14, 2026
Merged

echelon merged 6 commits into
storytold:mainfrom
dkhlapov:feat-ink-to-shape-arrows

Conversation

@dkhlapov

@dkhlapov dkhlapov commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Gap 12 in docs/gaps.md (Draw / ink): Ink to Shape recognises arrows.

WordCraft's own design. Word for Mac 16.113.4 has no Ink to Shape at all (checked by hand), so there was nothing to observe. This extends WordCraft's own recogniser (#395) with its own geometry.

What changed

  • crates/engine/src/cmd/ink_shape.rs: recognise now finds single-stroke arrows: a straight shaft, then two barbs at the tip, drawn shaft-first or head-first.

    • Tip: the first point near the farthest distance from the start, then walked forward while the distance keeps growing, with 0.5 pt of jitter allowed. It lands on the real tip even with dense pen sampling or when the pen overshoots on the way back from the first barb.
    • Shaft: checked against its chord with the same 6% tolerance as lines, so bowed and wobbly hand-drawn shafts count.
    • Head: exactly two barbs on opposite sides. Each points back at 15–75° and is 5–50% of the shaft long. They must be of similar size, and the pen must return close to the tip between them.
    • V, checkmark, L, hook, Y, k, zigzag and a line with a scribble all stay ink; the hook gives None.
  • draw.rs: an arrow becomes a straight connector with flips and an end arrowhead. That's how Insert › Shapes arrows are stored, so it saves to DOCX (a:tailEnd), draws on screen and in PDF, and can be moved like any connector.

  • Not done:

    • two-stroke arrows, because the convert path handles each stroke separately;
    • arrows with a closed triangle head.

    Both are noted in gap 12.

  • Docs:

    • docs/gaps.md gap 12;
    • docs/hardware-parity.md Pen / stylus row, now 🟡 (ink, eraser and Ink to Shape landed; pressure and Ink to Math are missing);
    • docs/ui-parity.md and docs/target-app-parity.md;
    • a ROADMAP.md progress-log entry;
    • each with its status line and revision history.

Tests (ink_shape.rs, draw.rs)

All failed before the change or the fix that needed them:

  • single-stroke arrows in several directions, both drawing orders;
  • hand-drawn strokes: a bowed shaft, wobble, a rounded tip, uneven barbs;
  • an overshooting return;
  • the barb-limit boundaries, both sides;
  • dense strokes sampled every 1 pt, so the tip lands within 1 pt of where it was drawn;
  • conversion to a connector with an end arrowhead and a DOCX round trip, including flips.

Guards: V, checkmark, L, hook (None), Y, k, zigzag and line plus scribble all stay ink.

cargo xtask ci: all 6 steps passed (fmt, clippy, test, assets, layers, wasm).

Review

  • The independent review asked that hand-drawn, bowed shafts be accepted. Fix round 2 found a pen overshoot at the tip still left arrows as ink. Fix round 3, by a fresh implementing agent, made the tip rule hold on densely sampled strokes. The final re-review approved and found no false positives on dense strokes.
  • Left as is:
    • very tiny arrows with very wide barbs (a shaft under about 15 pt at 75°) stay ink, which never produces a false arrow;
    • head_at_start is reserved for double-headed arrows.

🤖 Generated with Claude Code

@dkhlapov
dkhlapov marked this pull request as ready for review October 14, 2026 02:52
dkhlapov and others added 5 commits October 14, 2026 09:10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dkhlapov
dkhlapov force-pushed the feat-ink-to-shape-arrows branch from d49d211 to de99688 Compare October 14, 2026 07:12
# Conflicts:
#	ROADMAP.md
#	docs/gaps.md
#	docs/ui-parity.md
@echelon
echelon merged commit 666b9af into storytold:main Oct 14, 2026
@echelon

echelon commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution, @dkhlapov! This has landed in main. If you haven't already, come join us on Discord: https://discord.gg/artcraft

@dkhlapov
dkhlapov deleted the feat-ink-to-shape-arrows branch October 15, 2026 19:27
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.

2 participants