Stroke: custom arrowheads from an arrowheads file join the arrowhead menus

The Stroke panel menu's Edit Arrowheads… (stroke.arrowheads.edit) opens
Arrowheads.vectorcraft next to the preferences, creating it with one
example head when it is missing. Each symbol in the file is one head,
listed by name after the built-in heads in both arrowhead menus: it
points right, its registration point is the tip, and its height is drawn
as wide as the built-in heads. The file is read at startup and again
each time VectorCraft saves it; stroke.arrowheads.reload and
stroke.arrowheads.list read and list it.

Arrowhead gets a Custom variant, appended after the built-in names, that
carries the head's name and outline, so a document that uses one draws,
saves, reopens and exports it without the arrowheads file. stroke.set
takes {"custom": name} or the {"Custom": {name, path}} form that
document.inspect reports.

Part of #5421.
This commit is contained in:
dotCooCoo
2026-11-11 21:52:46 -08:00
parent 7f3a046b18
commit c1f7e2eeaf
59 changed files with 1143 additions and 59 deletions
+25
View File
@@ -3741,6 +3741,31 @@ the `…Open` rings…) and marks (`Bar`, `DoubleBar`, `DotOnBar`, `Slash`, `Dou
`arrowScale`, at least 0.25 pt. `LineArrow` has two arms of the head's weight (the line's weight at 100 % for lines of
0.25 pt or more) at right angles and spreads twice as wide.
Custom arrowheads come from the arrowheads file, `Arrowheads.vectorcraft` next to the preferences (none on the web or
in runs with `VECTORCRAFT_NO_PREFS`). `stroke.arrowheads.edit` (Stroke panel menu › Edit Arrowheads…) opens it, and
first creates it with one example head when it is missing. Each symbol in the file is one head, named after the
symbol and listed after the built-in heads in both arrowhead menus. These rules are VectorCraft's own: a head points
right, the symbol's registration point is its tip, and the art's height is drawn as wide as the built-in heads (four
head weights). The visible fills and the outlined visible strokes of its paths, compound paths and groups, and its
gradient meshes, make the head, with geometry effects applied and clip groups clipped, and the line stops halfway along its length. A head is
one solid shape in the stroke's paint: art at 0 % opacity is left out, and other opacities, blend modes and opacity
masks do not change the shape. The file is read when the app starts and again each time VectorCraft saves it;
`stroke.arrowheads.reload` reads it again. A file larger than 64 MB is not read, at most 256 symbols are read, and a
symbol that paints nothing, reaches more than 64 head weights from its tip, has more than 65,536 anchors in its art or
in the shapes it paints, or has more than 4,096 anchors once united is listed in `skipped`. `stroke.arrowheads.list` returns each head's `name`, `reach` and `halfWidth`, the `file`
path, the `skipped` symbols and any read `error`.
`stroke.set {endArrow: {"custom": name}}` puts a custom head on a stroke. The stroke keeps a copy of the head's art,
so the document draws it, saves it and exports it to SVG and PDF the same way without the arrowheads file.
`document.inspect` reports such a head as `{"Custom": {name, path}}`, which `stroke.set` takes back unchanged. The
help page [Apply stroke on an object](https://helpx.adobe.com/illustrator/using/stroke-object.html) describes
defining custom arrowheads in a separate arrowheads file.
```json
{"name":"run_command","arguments":{"command":"stroke.arrowheads.list","params":{}}}
{"name":"run_command","arguments":{"command":"stroke.set","params":{"ids":[9],"endArrow":{"custom":"Example Arrowhead"}}}}
```
## Stroke bounds and clicks
Visual bounds (Fit to Selected Art, Rasterize, exporting all art) and clicks on the canvas take