Repository navigation
Drawing export: SVG and PNG cut a picture to a detail view's boundary (#4890) - #10969
Merged
Merged
Conversation
CamWight
force-pushed
the
paper-clip-4890-a8c
branch
from
November 2, 2026 23:34
dc90dd5 to
ee1aa04
Compare
This was referenced Nov 2, 2026
CamWight
marked this pull request as ready for review
November 2, 2026 23:36
CamWight
force-pushed
the
paper-clip-4890-a8c
branch
from
November 3, 2026 11:46
ee1aa04 to
d0550d9
Compare
…angency-labs#4890 A8a) Scene::prepare_clipped(clips) cuts each group of an object to that object's Clip, a rectangle or a circle (a detail view's), and keeps what lies inside; prepare() is prepare_clipped with none. Prepared holds a Cow: a scene without clips is borrowed as it is, and Group and Scene are unchanged, so today's scenes are the same bytes. - Lines and arcs are cut where they cross the edge; a part is kept when its middle is inside, the edge included. Parts no longer than EPS go. - Kept parts that follow one another stay one open stroke. A stroke wholly inside is kept whole, closed if it was; a closed one cut open rejoins across its seam. - A dashed stroke keeps its pattern: each part's phase is where it starts along the stroke. Across a closed one's seam the pattern runs on only when its length is whole patterns, so the parts rejoin only then. - Checked: one clip an object, a rectangle from its lower-left to its upper-right corner or a circle with a radius above 0, within 1e5 mm; a clipped object's items strokes of lines and arcs. What the cuts made is validated again. SVG and PNG draw the cut scene through Prepared as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#4890 A8b) A clipped object's strokes may now hold any curve, not only lines and arcs, and its fills are checked against the clip. - A line or an arc is still cut where its equation says. Any other curve is halved while its control points lie either side of the edge (widened by EPS), until they span at most CUT_MM (1e-9 mm), and is cut there. A curve that needs more than MAX_HALVINGS halvings (one that runs this close along the edge) is refused as not supported yet. Each part is the same kind of curve as the whole. - Seg2::part gives the piece between two parameters, starting and ending exactly where split_at puts those points; a conic's tail is re-normalised, so its second parameter is carried into it. Seg2::MIN_SPLIT names split_at's distance from the ends. - A line or a circle within EPS of touching a circle only touches it: one cut there, never a sliver of chord. - A fill wholly inside its clip is kept and one wholly outside is dropped. One that crosses the edge, or lies round the whole clip, is refused as not supported yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NG writers (tangency-labs#4890 A8c) A picture wholly outside its object's clip is dropped when the scene is prepared. One crossing the clip's edge reaches its writer with the clip, on the grid item, since pixels can't be cut as geometry: SVG cuts it with a clipPath, the sheet PNG by whether each pixel's middle is inside. Both draw only the pixels that meet the clip's box. Text in a clipped object stays refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CamWight
force-pushed
the
paper-clip-4890-a8c
branch
from
November 3, 2026 12:52
d0550d9 to
af78dd6
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.
A detail view of a shaded view couldn't be exported: a picture inside an object cut to a boundary was refused. Now the SVG and sheet PNG exports cut such a picture to the boundary, a rectangle or a detail view's circle. So a detail view of a shaded view can be drawn. Shaded views and detail views are both planned for the first drawing release.
Part of #4890 (W10, the paper scene), into
drawings: pictures in a clipped object, cut by the SVG and sheet PNG writers (A8c). Stacked on #9840 (A8b), which refuses them today, and so on #9833 (A8a). The commits before the last are the stack's; this PR's own is the last. It closes the gap #9840 names: shaded views and detail views are both in the first release, and a detail view of a shaded picture couldn't be drawn.Changes a default: no
In
crates/geom:paper/clip.rskeeps or drops a picture and says whether one lies wholly inside;paper.rs'sPreparedkeeps the clips;paper/grid.rs'sGridItem::Picturecarries the clip to the writer. The rest is tests. These modules hold drawing data only, with no kernel geometry.What it does
Strokes and fills are cut as geometry when a scene is prepared. Pixels can't be, so a picture is cut by whichever writer draws it.
GridItem::Picture { picture, clip }hands the writer the clip.<clipPath>holding a<rect>or<circle>on the same nanometre grid as the lines, numbered in document order, so a scene writes the same bytes each time.GridItem::Picture { visible }): the picture's part on the sheet and inside its clip's box. They ask for and embed only the pixels that meet it, so a small detail of a large picture stays small, and one past the sheet's edge asks only for the sheet's part.(#4890 A8)), until text clips too.For #7626
pdf.rsis left alone here. It lives on #7626, and PDF isn't part of this PR.GridItem::Picturechanges shape, so that writer stops compiling at its rebase rather than silently drawing a whole picture past its clip. It then needs to honourclip, or refuse it by name.No detail view yet
No command makes a detail view yet, and nothing on
drawingssetsScene.clips. #9720 brings the boundary's geometry, with its records and commands still to come. So no user can reach this until then, andScene.clipswas set only in the local run below.Pictures
These come from a real app run, plain test design, but not from this PR's branch alone. It was a local mix, never pushed, of this PR and #10926 (the shaded view on paper), plus a small stand-in that gives one view a clip from a file and writes a sheet PNG beside each SVG. The view is a second top view of the milestone plate at 3:1, standing for a detail view.
The SVG in Chrome, the view cut by a circle, on its sheet beside its parent:
The SVG cut by a rectangle: both holes it crosses are cut at its edge.
The sheet PNG at 150 dpi, zoomed twice: a pixel is in or out by its middle, so the edge isn't smoothed.
What the run was tested with, and which limit applied. The mix takes the renderer from #10926's stack, which carries #6483's commits, so #6483's budget applied: 8 pixel tests a sample of the whole view, or 128 M if that's more, each triangle counted whole. On the plain plate the view drew at 1:1, twice its parent's scale, which is what's shown here. At 2:1 it was refused by name, and at 2:1, 3:1 and 5:1 cut to a 20 mm circle too: "projected product exceeds ... pixel tests". That limit is #6483's and is being fixed there, so a real detail view's scale isn't shown drawn yet.
drawingsdoesn't have that renderer until #6483 lands anddrawingstakesmain.Tests
<clipPath>andclip-path, y flipped as the lines are; each clip its own id; none for a picture wholly inside; only the clip's pixels asked for.<clipPath>only when the clip crosses the picture, and no image when it misses.Not covered
read_svghas no handling for<clipPath>, so from its code a clip's<rect>or<circle>would import as a drawn shape. It reads any SVG's that way today; not run here, and it would be its own small fix.On this head
Re-parented onto
drawings49a3ba1c0(#7430 landed) asaf78dd6b4. The landed tree is byte for byte our A5 commit's, so every commit of the stack keeps its tree and the checks below, run ond0550d9c2, hold unchanged.d0550d9c2overdrawingsd78895de4, local, Windows,--profile ci:-D warningsovergeom,ioandengine, all targets, pass;112e0a3d9an hour before:geom's library tests (A5 355, A8a 366, A8b 371, A8c 372) andio's paper tests (34, 34, 34, 38) pass, and on the topxtask lists,xtask layersandxtask wasm. The move tod78895de4changed one engine test line (below);d0550d9c2, overd78895de4:geom's library tests (372),io's paper tests (38) andengine's drawing and paper tests (199 + 2) pass;The planted faults of earlier rounds weren't rerun.
No full gate on this head.
What this rebase changed:
drawingsmoved fromd5fd14135tod78895de4(#10515, #7745, #10516, #11350, #11047, #9708, #11352). #9708 put text on the grid, beside the pictures. From a review of the stack:on_gridand both writers take it, where each worked out its own before;Integration status
Lands after #9840 and #9833 (#7430 has landed). #4891 stays the claim for #4890.