mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-13 09:39:52 +00:00
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:
+25
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user