feat(svg): SvgPath.parse - full SVG path grammar to native PathNode curves#172
Merged
Conversation
…urves New document.svg package: SvgPath.parse(d) / parse(d, viewBox) lowers the complete SVG 1.1 path grammar (absolute/relative M L H V C S Q T A Z, implicit repetition, exact quadratic-to-cubic elevation, S/T control reflection, elliptical arcs via the W3C endpoint-to-center algorithm in <=90-degree cubic slices, single-char arc flags) into normalized, y-flipped DocumentPathSegments; PathBuilder.svg(svgPath) drops them into addPath(...). Scanner/state machine lives in package-private SvgPathParser (extracted pre-commit to keep SvgPath under the 500-line rule; every branch driven through SvgPathTest). 14 parser tests incl. golden Material-heart icon, kappa check on a quarter arc, 270-degree slice count, compact flags, position-carrying syntax errors; svg-bridge builder test. Example ships the Material heart rendered at 72pt (page grew to 660pt, preview stays single-page). Full gate: 1276 tests, BUILD SUCCESS.
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.
What
The SVG milestone the path workstream was building toward:
SvgPath.parse(d)(+ viewBox overload) in the newdocument.svgpackage lowers the complete SVG 1.1 path grammar into normalized, y-flippedDocumentPathSegments, andPathBuilder.svg(svgPath)drops them straight intoaddPath(...)— any icon'sdstring renders as native PDF curves.M L H V C S Q T A Z, implicit repetition (moveto→lineto chains), exact quadratic→cubic elevation,S/Tcontrol-point reflection, elliptical arcs via the W3C endpoint-to-center algorithm (radii correction, ≤90° cubic slices), single-character arc flags (a1 1 0 011 1parses).IllegalArgumentExceptions carrying the character position.SvgPathParserpre-commit (500-line rule); every branch is driven through the public-API tests.Verification
SvgPathTestcases: triangle/relative/H-V/implicit-lineto, exact quad elevation values, S/T reflection coordinates, quarter-arc κ≈0.5523 check, 270°→3 slices, zero-radius arc→line, compact flags, golden Material heart end-to-end (all coordinates inside the unit box), flat-path degeneracy, six error contracts.PathBuilderTest.svgBridgeAppendsParsedSegments.vector-path.pdfpreview eyeballed: orientation correct, curves smooth, single page.package-info); full gate./mvnw verify -pl .— 1276 tests, 0 failures, BUILD SUCCESS.