Changelog
All notable changes to @draw/sketch. The format follows Keep a Changelog. New entries go under Unreleased.
Unreleased
Section titled “Unreleased”- Package scaffold.
PathandPathCommand, the plain path data every sketch function returns. An internal seeded generator backs the random choices and is not exported.roughEdgesandRoughEdgesOptions. Straight-edged outlines are drawn twice per edge with roughjs-style offsets, bow and overshoot, scaled byroughness. Roughness 0 returns the input segments exactly.roughCurve,RoughCurveOptionsandRoughCurve. Smooth outlines are resampled, jittered and drawn as two Catmull-Rom passes. A closed curve starts at a random offset and overlaps its start with a tail of one or two steps.basereturns the jittered points a fill hatches.passesoption onRoughEdgesOptionsandRoughCurveOptions.passes: 1draws only the first pass, for dashed and dotted strokes.inkOutlineandInkOptions. Freehand samples become a closed outline polygon of variable width with round caps, after streamlining. Pressure is the samples’ own or simulated from speed. A single sample is a dot.hachureFill,HachureOptionsandsolidFill. Hachure cuts the polygon with parallel scanlines at -49 degrees and draws each span twice with its ends fixed, so the lines stay inside the outline. Cross-hatch adds a second set at right angles. Solid returns the polygon as one closed path.paintShape,DrawOpandDrawing. A shape becomes an ordered list of stroke and fill operations in frame-local units: fill first, then the outline. Dashed and dotted strokes carry a dash pattern and draw one pass. Freehand is one filled ink outline. Text paints nothing.- Arrowheads in
paintShape. Each end paints itsarrow,bar,triangleordothead with Excalidraw’s sizes and angles, capped at half the arrow’s length. Heads stay solid on dashed arrows. PathCommandKindandDrawOpKind, named values for comparing path command and draw op kinds (ADR 0006). Internal comparisons use the shapes package’s named values.
Changed
Section titled “Changed”- A straight arrow’s shaft is drawn as one rough line, not a resampled curve, so it no longer wobbles at roughness 1 and above.
- A closed curve starts near its top and overlaps its start by a fraction of one step that ends slightly inside, as rough.js does. The old tail of one or two steps read as a hook on every ellipse.
- A closed curve’s second pass starts at its own random place near the top and does not overlap, as in rough.js. Both passes used to share one seam, which read as a doubled hook at roughness 2 and above.
roughCurveresamples to at most 512 points per pass, so a huge ellipse or arc no longer hangs.- Freehand ink follows perfect-freehand 1.2.2 more closely: points inside the first pen size are dropped, streamlining moves 57.5 percent per step, and simulated pressure warms up over the first 10 steps with no extra floor rate. A fast mouse stroke no longer starts with a fat blob.
paintShapesimulates pressure only when every sample’s pressure is 0.5, as a mouse reports. A pen held at a constant pressure now draws with that pressure.roughCurvetreats a negative roughness as 0, as its docs promise. It used to jitter by the negative amount.- Numeric literals in
srcare named constants, as the newno-magic-numberslint rule requires. Behaviour is unchanged. hachureFillcaps each set at 10000 lines, widening the gap on huge polygons. It cuts each edge only against the scanlines it spans and no longer overflows the stack on huge polygons. Output for normal shapes is unchanged.