Skip to content

2.4.0

Latest

Choose a tag to compare

@thednp thednp released this 24 Nov 08:46

What's inside

[2.4.0] - 2026-11-23

Breaking

  • The parser rejects a path that does not begin with a moveto command β€” parsePathString() relabelled the first segment of every path as an M, whatever it was, without touching its parameter list, so "h10" became [["M",10]] and "C1 2 3 4 5 6" became [["M",1,2,3,4,5,6]]; the damage downstream was silent and numeric (getPathBBox("h10") answered a box with a NaN height, getTotalLength("A5 5 0 0 1 10 10") answered zero for an arc that is 15.7 units long). The rewrite was written for one case β€” the leading relative moveto of PR #49, which is a pair of absolute coordinates β€” and it was over-generalised to every first command. The leading m is rewritten and every other first command is rejected with a TypeError, for a path string and for a path array alike, so the parser agrees with isValidPath() and with the SVG spec, where a path that does not begin with a moveto is in error:
    SVGPathCommander.parsePathString("m10 10");
    // => [["M", 10, 10]] β€” the leading relative moveto is a pair of absolute coordinates
    SVGPathCommander.parsePathString("L10 10");
    // => TypeError: SVGPathCommanderError: path data must begin with a moveto command
  • segmentToCubic() returns a PathSegment β€” the function declared that it returns an MSegment or a CSegment, but it returns every other segment unchanged: the smooth cubic, the smooth quadratic, the horizontal and the vertical lineto fall through to the last line of the function. The declaration was a lie that the cast at that line told the type system to believe.
  • resamplePath() returns a PathArray β€” a multi-subpath result holds one M command for every source sub-path, so the narrower MorphPathArray type could not describe the result. The single-subpath helper keeps its morph-specific type.
  • equalize() and equalizePaths() return PathArray tuples β€” a multi-subpath result holds one M command for every matched contour, so the narrower MorphPathArray type could not describe the result. equalizeSegments() keeps its morph-specific type because it only accepts single-subpath paths.
  • fixPath() returns the fixed path instead of void β€” the helper documents that it removes an unnecessary closing segment, but parsePathString() clones an array input, so the old in-place splice never reached the caller's array and the return value was undefined. The helper now returns a fixed copy and leaves the source path unchanged; equalizeSegments() consumes that copy, so the redundant Z is actually removed before equalization.
  • The morphing tools preserve input closure by default instead of leaving the result open β€” every closed contour now retains its Z command, open paths stay open, and a closed/open pair is closed on both sides to keep the commands compatible. Pass close: false to restore the previous open-result behavior.

Added

  • offsetPath() β€” the offsetting of a path along its normals: the path is sampled along its length, every sample is shifted along the normal of the path, and the result is a path of straight lines. The side option is literal β€” the left side is the left normal of the direction of travel, the same normal getPropertiesAtLength() returns β€” and the both side is the outline of the stroke, the band between the two sides of the path:
    SVGPathCommander.offsetPath("M0 0L100 0", 10);
    // => [["M", 0, 10], ["L", 100, 10]]
    SVGPathCommander.offsetPath("M0 0L100 0", 10, { side: "both" });
    // => [["M", 0, 10], ["L", 100, 10], ["L", 100, -10], ["L", 0, -10], ["Z"]]
  • The offset accepts the join option ("miter", the default, "bevel" or "round"), the miterLimit option (the ratio of the miter length to the offset distance, 4 by default), the cap option ("butt", the default, "square" or "round"), the steps option (the number of the intervals a curve is sampled with, 16 by default) and the precision option (the number of the decimals of the result, 4 by default). The defaults are the initial values of the SVG presentation attributes.
  • SVGPathCommander#offset(distance, options) β€” the instance method of the offset, the counterpart of simplify():
    new SVGPathCommander("M0 0L100 0").offset(10).toString();
    // => "M0 10L100 10"
  • joinPath() β€” the joining of two paths into a single path with two sub-paths:
    SVGPathCommander.joinPath("M0 0L100 0", "M0 100L100 100");
    // => [["M", 0, 0], ["L", 100, 0], ["M", 0, 100], ["L", 100, 100]]
  • reverseSubPath() β€” the reversing of one sub-path of a path, the other sub-paths are left untouched:
    SVGPathCommander.reverseSubPath("M0 0L100 0ZM0 100L100 100", 1);
    // => [["M", 0, 0], ["L", 100, 0], ["Z"], ["M", 100, 100], ["L", 0, 100]]
  • SVGPathCommander#join(path) and SVGPathCommander#reverseSubPath(index) β€” the instance methods of the two, chainable like the rest of the class API
  • isPointInPath() β€” the hit test of a filled shape: the path is flattened into polygons and the point is tested against them with the nonzero or the evenodd fill rule, the two rules of the SVG fill-rule attribute:
    SVGPathCommander.isPointInPath("M0 0L100 0L100 100L0 100Z", { x: 50, y: 50 });
    // => true
    SVGPathCommander.isPointInPath(
      "M0 0L100 0L100 100L0 100ZM25 25L75 25L75 75L25 75Z",
      { x: 50, y: 50 },
      {
        fillRule: "evenodd",
      },
    );
    // => false β€” the inner square is a hole with the evenodd rule
    A point on the boundary of the shape is inside of it, the way the browser answers it with isPointInFill(), and the curves of the path are approximated with chords, so the answer can differ from the exact geometry for the points that are within the tolerance (0.1 by default) of the boundary of a curve.
  • SVGPathCommander#isPointInPath(point, options) β€” the instance method of the hit test, the counterpart of isPointInStroke()
  • isPointInStroke() accepts the width option β€” the tool answered whether a point is on the path, which is the path itself and not the band a stroke paints around it, so the hit test of a stroked shape was impossible. With a width the stroke is the band around the path: the point is in the stroke when it is at most half the width away from the path. The ends of an open path are treated as if the stroke had round caps:
    SVGPathCommander.isPointInStroke("M0 0L100 0", { x: 50, y: 5 });
    // => false β€” the point is not on the path
    SVGPathCommander.isPointInStroke("M0 0L100 0", { x: 50, y: 5 }, { width: 10 });
    // => true β€” the point is inside the stroke
    The answer without a width is the same as before, so the change is additive.

Fixed

  • equalize() preserves the input closure by default β€” closed contours keep their Z command through both strategies, including every contour of a multi-subpath result, so the final morph frame no longer acquires a spurious open-path join. Open inputs stay open, a closed/open pair is closed on both sides to keep the commands compatible, and close: false remains the explicit opt-out
  • Multi-subpath morphing matches outer contours only to outer contours and holes only to holes β€” an unmatched contour collapses at its own centroid instead of taking the opposite fill role, so target holes no longer disappear in the intermediate frames
  • Morph rotation scores every corresponding coordinate, including BΓ©zier control points, instead of scoring only the endpoints β€” the arc-length strategy no longer chooses a rotation with matching vertices but twisted curve handles
  • getPathBBox() and arcTools.getArcBBox() answer the bounds of an arc correctly β€” the bounds were computed from the end point of the arc and the extrema of the ellipse, so the start point of the arc was dropped and the box of an arc did not contain the arc:
    SVGPathCommander.arcTools.getArcBBox(0, 0, 50, 50, 0, 0, 1, 50, 50);
    // => [50, 50, 50, 50] β€” the start point (0, 0) was gone
    An extremum of the ellipse is on the arc when its angle is in the swept interval, and that was decided with two probe points inside the arc, so an extremum between the probes and the end of the arc was missed as well:
    SVGPathCommander.getPathBBox("M-40 -20A10 10 30 0 0 -30 -40");
    // => x2: -30 β€” the rightmost point of the arc is at -23.82
    The bounds are the two end points and the extrema the sweep covers now. A degenerate arc β€” the same start and end point, which the spec omits β€” answers the box of its single point instead of the box of the ellipse, and an arc with a zero radius answers the box of the straight line to its end point, like the length does.
  • The arc queries answer numbers for arcs whose ends are diametrically opposite β€” the cosine of the angle between the two ends of a diameter can land a hair outside of the [-1-1] range, and acos() of a value under -1 is NaN, so the sweep of the arc was NaN and so were the length, the point at a length and the frame at a length:
    SVGPathCommander.getTotalLength("M-40 -20A10 10 30 0 0 -30 -40");
    // => NaN
  • getRectanglePath() builds the rounded corners of a rectangle with elliptical arcs, like the spec of the <rect> element β€” the corners were smooth cubic segments, and the reflected control point of a smooth cubic follows a line command, so it collapsed to the current point and the corner was a cusp: the length of the rectangle was 0.22 % too long and its area was 0.12 % too big
  • getRectanglePath() follows the auto rules of the radius of the corners β€” a missing rx takes the value of ry and a missing ry takes the value of rx, so a <rect ry="10"> is a rounded rectangle now; an explicit zero still disables the rounding and a radius bigger than half of the size of the rectangle is clamped to it
  • isMultiPath() answers false for an empty or a malformed path array instead of throwing β€” isPathArray() rejects an empty array, so the predicate fell through to its TypeError and equalize("", "") and equalizePaths("", "") failed with "expected string or PathArray" for an input that is a path; a malformed segment is now answered false too, as the 2.3.6 entry of isPathArray() promised, and only a value that is not a path at all throws
  • getPropertiesAtPoint(), getClosestPoint() and isPointInStroke() now find the closest point on the closing segment of a closed sub-path of a multi-subpath path β€” the coarse scan of the path samples the start of a closed sub-path twice, once at the start of the sub-path and once at the end of its closing segment, and it kept the first of the two equally close samples, so the refinement walked away from the closing segment and the point was reported at the distance of the start of the sub-path:
    SVGPathCommander.getPropertiesAtPoint("M0 0L100 0L100 100L0 100ZM50 50L150 50", { x: 0, y: 1 });
    // => { closest: { x: 0, y: 1 }, distance: 0, segment: { segment: ["Z"], … } }
    The scan now collects the local minima of the distance and the search refines around every one of them, so a path that passes near the point more than once is searched at every one of those places. A path that runs at a constant distance from the point β€” a circle around it β€” has no minimum, and the noise of the samples is not read as one.
  • getPropertiesAtPoint(), getClosestPoint() and isPointInStroke() now find the closest point on the closing segment of a closed path β€” the search starts at the beginning of the path and walks towards the end, so it could not walk over the end of a path that ends where it starts, and a point on the closing segment was reported at the distance of the start of the path:
    SVGPathCommander.getPropertiesAtPoint("M0 0L100 0L100 100L0 100Z", { x: 0, y: 1 });
    // => { closest: { x: 0, y: 1 }, distance: 0, segment: { segment: ["Z"], … } }
    The length table of the path knows whether the path is a loop now, and the search walks over the end of a loop the way it walks over the end of a segment.
  • resamplePath() resamples every sub-path on its own instead of flattening a multi-subpath path into one continuous polyline β€” the old implementation ignored the break between two sub-paths, so the result connected the body of an icon to its eyes and destroyed the shape. The count option is the number of points of every sub-path now, and the result keeps one M command for every source sub-path:
    SVGPathCommander.resamplePath("M0 0L10 0M20 0L30 0", 2);
    // => [["M", 0, 0], ["L", 10, 0], ["M", 20, 0], ["L", 30, 0]]
  • The arcLength strategy no longer bulges across the joints of the source path β€” the resampler fitted one cubic to a span that could cross several source segments, so the fitted curve departed from the source by as much as 0.456 units on the demo shapes. Each span is now the exact de Casteljau sub-curve of the source, and every source segment boundary is an arc-length knot, so the corners and the shape of the source are preserved.
  • The arcLength strategy keeps every sub-path separate and complete β€” the number of points is chosen for each sub-path, the source segment boundaries are kept whenever the requested count allows it, and an explicitly under-sampled sub-path uses the documented best-effort fallback instead of dropping geometry.
  • Multi-subpath morphing no longer drops an outer contour or a hole β€” outer contours only match outer contours and holes only match holes. The paths are reversed as whole paths, so the outer/hole relationships are preserved, and an unmatched contour receives a placeholder at its own centroid instead of taking the opposite fill role. All 42 ordered pairs of the demo shapes now keep their geometry and topology with both the segment and the arcLength strategy.
  • getPropertiesAtPoint(), getClosestPoint() and isPointInStroke() no longer report a materially wrong distance on a very long path β€” the refinement precision had a relative floor, so a narrow curve feature could be missed on a path of millions of units. The refinement is now capped at an absolute precision of 1e-6 length units.
  • The exact straight-segment projection no longer replaces a nearer result with a slightly farther tie, and a zero-length moveto point is considered as a point projection. The returned segment metadata now belongs to the same measured segment as the reported closest point, including at moveto and closing-segment boundaries.
  • getPropertiesAtPoint(), getClosestPoint() and isPointInStroke() no longer miss the closest point of a path shorter than the old 8-unit scan step β€” the coarse scan is scaled with the length of the path, the end of the path is sampled explicitly, and a straight segment is answered with the exact projection of the query point:
    SVGPathCommander.getPropertiesAtPoint("M7.759 2.722L12.968 3.144L5.288 5.065", {
      x: 1.083779092102759,
      y: 3.890545689621021,
    }).closest;
    // => { x: 5.288, y: 5.065 }

Performance

  • parsePathString() is 1.8x faster on a 4 000 segment path (1.75 ms -> 0.95 ms) β€” the parser looked the number of the parameters of a command up in an object, by the lowercased command, for every segment it scanned; the lookup is now by character code, and the command is not lowercased twice per segment. The parser answers the same paths and the same errors.
  • normalizePath() is 1.8x faster on a 4 000 segment path (0.37 ms -> 0.21 ms) β€” the normalized segment was built with three arrays (a copy of the values, a map over them and a concatenation), and the map was computed for every segment, including the ones that never used it; the segment is now built in one pass. optimizePath() and reversePath() normalize a path too and get faster with it.
  • optimizePath() is 2.3x faster on a 4 000 segment path (4.1 ms -> 1.8 ms) β€” the rounded segment was built with three arrays (a copy, a map and a concatenation) and the absolute and the relative form of a segment were compared by building their strings; the rounded segment is now built in one pass and the length of the string of a segment is computed without building it. The optimizer answers the same paths.
  • getPropertiesAtPoint(), getClosestPoint() and isPointInStroke() measure the path once β€” the search built a length table from a normalized copy of the path and then asked getPropertiesAtLength() for the segment at the answer, which measured the path a second time; the length table is now built from the shared measure pass, so the normalization and the second measurement are gone: 1.5x faster on a 4 000 segment path (3.3 ms -> 2.2 ms), with the same answers β€” the two implementations agree on every path of a 1 000 case random corpus
  • The length queries are much faster β€” getTotalLength() is 4x faster on a path of 4 000 lines (1.3 ms -> 0.3 ms) and 2.3x faster on a path of 4 000 curves (3.5 ms -> 1.5 ms), and getPropertiesAtLength() is 2.7x faster on the lines (0.9 ms -> 0.3 ms) and 2.3x faster on the curves (3.7 ms -> 1.6 ms). The measure pass copied every absolute segment, sliced the end point of every segment into a throw-away array and read the parameters of a segment with an array destructuring, which allocates an iterator for every segment; the parameters are read directly now and the copy is gone. The length of a line is computed without the two point arrays it needed, and the quadrature of the length of a curve computes the speed of the curve without a point per sample. The answers are the same: a differential harness over 2 000 random paths answers the same lengths, the same points and the same frames, bit for bit
  • The closest point search builds one set of measures instead of two β€” the length table held a copy of every measure of the path, with the geometry of the measure in it; the table holds the measures of the path now, so a search of a 4 000 segment path is 1.5x faster (1.7 ms -> 1.2 ms)

Changed

  • The demo in docs/ covers the features of 2.4.0 β€” the process page has the simplification, the offsetting, the join, the reverse of a single sub-path, the hit test of the filled shape and of the stroke, and the frame at a length, and the morphing page has the resampling and the equalize() facade with its strategy and its point count
  • The simplification tolerance of the demo is a percentage of the source shape's diagonal and the absolute tolerance is printed with the result β€” the old fixed value of 1 unit was about 6 % of a 16-unit icon and could destroy a small shape. The library API keeps its absolute tolerance in units
  • splitPath(), simplifyPath() and getPropertiesAtLength() no longer add an implicit moveto to a path that does not begin with one β€” the parser rejects such a path now, so the three of them have nothing left to paper over
  • transformPath() no longer keeps a leading relative moveto relative β€” the parser rewrites it as an absolute one, which is the same pair of coordinates
  • The svg-path-commander/util entry holds every standalone tool, including the morphing and intersection engines; the package and JSR exports maps expose only the main entry and the utility entry
  • Rebuilt dist and docs bundles

Known limitations

  • The offset of a path is not cleaned up: an offset distance larger than the local radius of curvature of the path produces a self-crossing curve, and an inner offset that overlaps itself is not trimmed. The removal of the self-intersections needs a polygon clipping pass, and it is not part of this release.
  • A multi-subpath morph fallback that pairs an outer contour with a hole keeps their opposite winding, so that pair can interpolate with a twist. Matched contours are never reversed independently because reversing a hole on its own would change the fill topology of the path; the paths are reversed as whole paths instead.

[2.3.6] - 2026-11-20

Added

  • getPropertiesAtLength() returns the frame of the path at the given length β€” the point at that length, the unit tangent vector, the unit normal vector (the left normal of the tangent) and the angle of the tangent in degrees; the result is the union of the segment metadata and the frame, so the existing destructuring of { segment, index, length, lengthAtSegment } keeps working
  • SVGPathCommander#getPropertiesAtLength(length) β€” the instance method of the frame, the counterpart of getPointAtLength():
    new SVGPathCommander("M0 0L100 0").getPropertiesAtLength(50);
    // => { segment: ["L", 100, 0], index: 1, length: 100, lengthAtSegment: 0,
    //      point: { x: 50, y: 0 }, tangent: { x: 1, y: 0 },
    //      normal: { x: 0, y: 1 }, angle: 0 }
  • simplifyPath() β€” the curve-preserving simplification of a path: straight-line runs are reduced with Douglas-Peucker and curve runs are fitted with adaptive Schneider cubic BΓ©ziers. Arcs and original curves are retained whenever fitting would not reduce the segment count, and every source sub-path and closure is preserved:
    SVGPathCommander.simplifyPath("M0 0L10 0L20 0L30 0", 1);
    // => [["M", 0, 0], ["L", 30, 0]]
  • SVGPathCommander#simplify(tolerance) β€” the instance method of the simplification, the counterpart of normalize():
    new SVGPathCommander("M0 0L10 0L20 0L30 0").simplify(1).toString();
    // => "M0 0L30 0"
  • equalize() β€” the recommended entry point for morphing two paths: it picks the right strategy for the paths, aligns their points and normalizes their winding, so the two paths hold the same number of segments of the same type:
    const [eq1, eq2] = SVGPathCommander.equalize("M0 0L100 0L50 100Z", "M0 0L100 0L100 100L0 100Z", {
      strategy: "arcLength",
    });
    // eq1.length === eq2.length === 6 β€” ready for morphing
  • resamplePath() β€” the resampling of a path to a given number of points, distributed along its length: the source segment boundaries and corners are points of the result too when the requested count allows it, so the shape of the path keeps its vertices:
    SVGPathCommander.resamplePath("M0 0L100 0L100 100", 3);
    // => [["M", 0, 0], ["L", 100, 0], ["L", 100, 100]]
  • equalizeSegments() and equalizePaths() accept the strategy option β€” segment (the default) splits the segments of the paths, so the points of the result are the points of the paths, while arcLength distributes the result points along the path length and keeps the source segment boundaries and corners when the requested count allows it
  • equalizeSegments() and equalizePaths() accept the align option β€” the points of the second path are rotated onto the points of the first one by default, align: false keeps them where they are
  • equalizeSegments() and equalizePaths() accept reverse: "auto" β€” the path that is reversed is the one that leaves the two paths closest to each other, instead of always the second one
  • equalizeSegments() and equalizePaths() accept the mode: "line" option β€” the result of the equalization is a polyline, even when the paths hold curves

Fixed

  • samplePolygon() no longer throws on a quadratic segment β€” the winding of a path with a Q segment could not be read, so the equalization of such a path failed with path command "Q" is not supported
  • getPointAtLength() no longer jumps to the end of a zero radius arc β€” the SVG spec treats a zero radius as a straight line to the end point, and the length of such an arc was already measured that way, but the point lookup returned the end point for every distance along it
  • reversePath() no longer corrupts the geometry of a T segment β€” a reversed T was emitted as the T shorthand whenever the original predecessor was not a Q/T, but in the reversed path the predecessor of a segment is its original successor, so when that successor was a Q the shorthand reflected the Q's control point instead of the T's own control point and silently changed the curve; e.g. M0 0L10 0T20 20Q30 30 40 40 was off by up to 21 units β€” the shorthand is now kept wherever it is provably safe and falls back to an explicit Q otherwise
  • arcToCubic() no longer produces NaN control points for a zero radius arc β€” the SVG spec treats a zero radius as a straight line to the end point, which is what the conversion produces now
  • getArcLength() measures a zero radius arc as the straight line to its end point, the same as getPointAtArcLength() already did
  • arcToCubic() uses the absolute value of a negative radius, as the spec says β€” the converted curve used to be a different shape than the arc it came from, and the length of pathToCurve(arc) was 7.4 % off the length of the arc itself
  • getPathSplits() no longer hangs when the target cannot be reached β€” a target below the segment count, a fractional target and a non-finite target all made the adjustment loop wrap around forever (the hang was live: getPathSplits([['M',0,0],['L',10,0],['L',20,0]], 2) never returned); the target is now clamped to the segment count, fractional targets are floored and non-finite targets are rejected with a TypeError
  • equalizeSegments() and equalizePaths() no longer mutate the module level defaults β€” the options of the first call were written into the defaults object, so every later call without options inherited them (mode: "curve" leaked, and so did reverse: false, which equalizePaths() passes for every matched subpath pair and which permanently disabled the winding normalisation of every later equalizeSegments() call β€” two paths with an opposite winding were then morphed without being aligned)
  • Empty input has a defined contract everywhere β€” getPathBBox([]) returns a zeroed bounding box, getPointAtLength([], 10) returns { x: 0, y: 0 }, isClosedPath([]) returns false, getPropertiesAtPoint([]) returns { closest: { x: 0, y: 0 }, distance: Infinity }, getSegmentOfPoint([]) returns undefined, isPointInStroke([]) returns false, getClosestPoint([]) returns { x: 0, y: 0 }, getPropertiesAtLength([]) returns a synthetic ["M", 0, 0] segment and isValidPath(" ") returns false; getPathBBox() was the worst of them β€” the guard tested the truthiness of the input, so an empty array (which is truthy) slipped through and the result was { x: Infinity, y: Infinity, x2: -Infinity, cx: NaN }
  • getPropertiesAtLength() no longer returns undefined for a negative distance (which made getSegmentAtLength(path, -5) throw) β€” a negative distance takes the same early return as a distance of zero
  • A malformed segment ([[]], [[1, 2, 3]]) now throws a descriptive TypeError naming the offending index, instead of "Cannot read properties of undefined" from deep inside the iterator
  • roundPath() no longer modifies the caller's array β€” it returned the caller's own array with the segments replaced in place
  • transformPath() no longer writes the default origin into the caller's transform object, where it was the same array as SVGPathCommander.options.origin β€” a caller who mutated the origin they passed in corrupted the library's global default for the rest of the process
  • getSVGMatrix() falls back to the default origin instead of throwing "origin is not iterable"
  • splitLineToCount() splits a line into equal lengths β€” the breakpoints were computed from the original start point, so a 90 unit line split in three became 30, 15 and 45 units long; this is the point distribution equalizeSegments() is built on, so an edge split in ten used to bunch its points at the start instead of spreading them evenly
  • matchPaths() no longer destroys the caller's arrays β€” it sorted them in place and emptied them with shift()
  • splitPath() no longer drops the segments before the first M and always returns absolute segments, as its docstring promises
  • isPathArray() β€” and with it isMultiPath(), isAbsoluteArray() and isRelativeArray() β€” answers false for a malformed segment instead of throwing
  • projection2d() no longer returns Infinity or NaN when the relative position has no z β€” the guard Math.abs(originZ) / Math.abs(relativePositionZ) || 1 returns Infinity for a zero denominator, and Infinity is truthy, so the fallback never applied
  • classifyPaths() no longer inverts outer and inner paths β€” the classification was purely signedArea > 0 ? outer : inner, but in the SVG coordinate system (y pointing down) the usual outer contour has a negative signed area, so a square and its hole both came back as holes; a path is now an inner path when another path of the same set contains it, which does not depend on the winding at all
  • The parser accepts a leading zero again (M09 09) β€” the SVG path grammar defines a number as a digit sequence and every browser accepts it; the rejection came from a borrowed Esprima rule that belongs to the JavaScript numeric literal grammar
  • The parser rejects a number it cannot represent (M1e999 0) with a descriptive TypeError, instead of parsing it into an infinite coordinate that propagated into every length, bounding box and transformation
  • pathToAbsolute() absolutizes a leading relative moveto β€” the SVG spec says "If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates", but absolutizeSegment() returned the first segment untouched
  • getPolyPath() drops an incomplete point pair instead of producing a segment with an undefined coordinate
  • getSegmentAtLength(path, Infinity) clamps to the last segment like every other out of range distance, instead of returning the first one
  • An explicit origin: [x, y, 0] is no longer overwritten by the instance origin β€” originZ || cz treated a zero as missing
  • A non numeric transform value is ignored instead of being stored as NaN β€” typeof Number(v) === "number" is true for every value

Performance

  • getPropertiesAtLength() no longer measures the path O(nΒ²) times β€” it truncated the path and called getTotalLength() on the truncated copy once per segment; it now reads the shared measure table and picks the segment with one scan: 16.7x faster at 200 segments and 514x at 4 000 (1 105 ms -> 2.15 ms)
  • getPropertiesAtPoint() and getPointAtLength() are served from a length table β€” every sample of the closest point search walked the whole path from the start, so the search was quadratic: 21.5x faster at 50 segments and 489x at 1 600 (615 ms -> 1.26 ms)
  • getPropertiesAtPoint() no longer normalizes the path again for every sample of its search β€” 2.7x - 3.1x faster
  • getRotatedPath() no longer materialises a copy of the path for every possible start segment β€” at 4 000 segments the search needed 145 MB of heap for the copies alone and 933 ms; it now needs 2 MB and 3 ms
  • getDrawDirection() converts the path to a curve once instead of twice β€” 1.78x faster on a 6 000 segment path (12.80 ms -> 7.19 ms)
  • The parser no longer builds a 25 element array for every character it reads β€” 5.47x faster (20.55 ms -> 3.75 ms per 1 000 000 calls)

Changed

  • The mode option of equalizeSegments() accepts "line" β€” the option was documented but not implemented: a "line" mode fell through to the curve branch, so the result of the equalization always held cubic segments
  • The frame of getPropertiesAtLength() shares one t ratio between the point and the tangent β€” the point and the frame are computed from the very same spot on the curve, which is 1.9x - 3.7x faster than looking both up separately
  • The Douglas-Peucker simplification splits a range at its worst point and in its middle when the worst point sits at the edge of the range β€” a split at the edge alone makes the recursion as deep as the range is long, which was quadratic on a path that alternates between two sides of a line: a 4 000 curve path went from 1 090 ms to 17 ms, and the result keeps the same shape within the tolerance
  • getTotalLength() and getPathSplits() now share one length measurement pass β€” measureSegments() yields the length of every segment together with the length accumulated before it, so the two can no longer disagree and getPathSplits() no longer computes every segment length twice; the pass handles every command the way getTotalLength() does, where the old getPathSplits() measured H, V and Z segments as cubics and produced NaN for them
  • equalizeSegments("", "") returns [[], []] instead of [[], null] β€” an empty path has no rotation, and the morph facade no longer reports a null one
  • The benchmark harness (scripts/bench.js) measures with performance.now() instead of new Date().getTime() (1 ms resolution, on operations that take single-digit milliseconds), runs 30 times after 5 warmups and reports the median and the best of the runs in separate columns; it only rewrites the README when --write is passed, so vpr bench no longer leaves the working tree dirty
  • interHelper imports distanceEpsilon directly instead of through the barrel, which removes the import cycle between the intersection engine and src/util.ts
  • Nine @example blocks were corrected to match what the code returns (getPathArea, getTotalLength, pathToCurve, toCurve, normalize, reversePath, optimizePath, transformPath)
  • Updated dev dependencies: vite-plus 1.7.0, vitest / @vitest/* 5.1.0, vite -> @voidzero-dev/vite-plus-core 8.3.8000
  • Rebuilt dist and docs bundles

Full Changelog: 2.3.5...2.4.0