mirror of
https://github.com/excalidraw/excalidraw.git
synced 2026-12-06 11:12:51 +03:00
* feat(editor): fit arrowheads to short last segments Arrowheads used to shrink to half of the last segment, so multi-segment arrows ending in a short segment got near-invisible heads. They now use the whole last segment, or extend past its start where the shape allows: - triangle: grows until its base reaches the previous segment - arrow: widens as it shrinks (20° -> 30°), grows to half its size while its sides stay a stroke width off the previous segment - circle: grows freely (no direction), also on curved arrows - bar: ends stay closer to the tip than to the previous segment - diamond: back vertex reaches the corner - cardinality markers: scaled as a whole to fit the last segment - elbow arrows: the corner rounding is taken into account Single-segment and curved arrows keep the old sizing, except circles. Claude Opus 5.5 (xhigh) * fix(editor): fill arrowheads along their outline rough.js jitters a solid fill separately from the outline (by up to 2px), which on shapes as small as arrowheads made the fill stick out, and the repeated closing point of triangles/diamonds drew a stray hair at the tip. - triangle, diamond and circle arrowheads are drawn as a single rough stroke, and filled along that stroke - polygon arrowheads keep their corners in place, only edges bow - fewer ops: faster to generate and draw Claude Opus 5.5 (xhigh)
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
|
import { pointFrom } from "@excalidraw/math";
|
|
|
|
import type { LocalPoint } from "@excalidraw/math";
|
|
|
|
import { ShapeCache } from "../src/shape";
|
|
|
|
import type { Op } from "roughjs/bin/core";
|
|
|
|
describe("arrowhead shapes", () => {
|
|
it.each(["triangle", "diamond_outline", "circle"] as const)(
|
|
"fills %s arrowheads along their outline",
|
|
(arrowhead) => {
|
|
const arrow = API.createElement({
|
|
type: "arrow",
|
|
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(100, 0)],
|
|
endArrowhead: arrowhead,
|
|
roughness: 2,
|
|
});
|
|
const [, head] = ShapeCache.generateElementShape(arrow, null);
|
|
const [fill, outline] = head.sets;
|
|
const getCurves = (ops: Op[]) =>
|
|
ops.filter((op) => op.op === "bcurveTo").map((op) => op.data);
|
|
|
|
expect(fill.type).toBe("fillPath");
|
|
expect(outline.type).toBe("path");
|
|
// the fill only joins up the outline's curves
|
|
expect(getCurves(fill.ops)).toEqual(getCurves(outline.ops));
|
|
},
|
|
);
|
|
});
|