Repository navigation
feat: line style (dashed, dotted, dash-dot) - #202
Merged
Merged
Conversation
The lineStyle property and the Types.LineStyle type: solid (the default), dashed, dotted or dash-dot, with the dashes and the dots following lineWidth. The pencil, line, arrow (its shaft), rectangle, rectangle label, circle and polygon draw it, and the polygon in progress is shown in it. The brush is shared by the tools, so the highlighter takes it back to solid. The style is saved with the object by toJSON() and loaded by fromJSON(). The showcase has the line styles in the Line section.
tbolis
force-pushed
the
feat/line-style
branch
from
October 30, 2026 15:20
f4cdbe4 to
5fb0645
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
lineStyleproperty and theTypes.LineStyletype:"solid"(the default),"dashed","dotted"or"dash-dot".lineWidth. A line thinner than 2 pixels has the pattern of one of 2, so that it is seen.lineStyleis for the next drawing, what is drawn already keeps its style.toJSON()and loaded byfromJSON()with the object (strokeDashArrayandstrokeLineCap).setBrushStroke(): the highlighter takes the brush back to solid, and the style of the pencil is not left on it.LineStylein the exports. CHANGELOG: an entry under Added.Checks
yarn format:check,yarn lint,yarn typecheckandyarn buildpass.yarn test: 392 passing and 1 todo. The new tests areLineStyle.spec.tsx(each tool and each style, solid by default, a change of the property,toJSON()andfromJSON(), the arrow head, the brush and its reset by the highlighter, the polygon in progress) and the tests oflineStrokeinutils.spec.ts. With the feature switched off 35 of them fail.In headless Chrome, a page with fabric and the options the tools set: dashed, dotted (round dots) and dash-dot lines, rectangles and circles, at widths 1, 4 and 10.
Not checked: the showcase in a browser, a physical touch device, and browsers other than Chrome.
Notes for review
Arrow.ts, in other lines. A conflict, if any, is small.lineStyletakes the names only. A custom dash array is not part of this.