Repository navigation
Drawing export: ellipses, hyperbolas and other complex curves draw smoothly in every format (#4890) - #9846
Merged
Conversation
CamWight
force-pushed
the
paper-curves-4890-a3b
branch
2 times, most recently
from
November 2, 2026 02:10
341eb0a to
c39154a
Compare
CamWight
force-pushed
the
paper-curves-4890-a3b
branch
from
November 2, 2026 20:29
c39154a to
4a29e90
Compare
CamWight
marked this pull request as ready for review
November 2, 2026 20:32
… grid (tangency-labs#4890 A3b) A conic of weight other than 1 and a Bézier above degree 3 become cubic Béziers within 1e-4 mm of the curve (`paper::cubic_pieces`), so the walk takes them and every writer draws them with the cubics it already writes. Each piece's cubic has the curve's ends and end tangents; its distance is bounded from the Bernstein form, not sampled: for a Bézier, by the control points of its difference with the cubic raised to its degree; for a conic, by Q·D − N over the denominator's least value. A piece over the error is halved exactly and tried again, up to 4096 a curve and 1,000,000 a scene; past that the curve is refused, never drawn coarser. The walk counts the cubics it made. Circular arcs are left to the shared `paper::cubics` helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CamWight
force-pushed
the
paper-curves-4890-a3b
branch
from
November 3, 2026 14:18
4a29e90 to
7b21de6
Compare
This was referenced Nov 4, 2026
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.
Drawing exports could draw lines, arcs and simple curves, but not ellipses, hyperbolas or higher-order curves. Now each one becomes curves that every format can write, within 0.0001 mm of the true shape. A curve that needs too many pieces is refused. It is never drawn coarser.
Part of #4890 (W10, the paper scene), into
drawings: ellipses, hyperbolas and higher Béziers as cubics on the grid (A3b). This PR holds only its own commit.Changes a default: no
In
crates/geom:paper/cubic_pieces.rsis new and turns a conic or a high-degree Bézier into cubics for paper.paper/grid.rscalls it from the walk onto a writer's grid,paper.rsdeclares it, andpaper_tests.rsandcubic_pieces_tests.rstest it. No kernel code is involved.What it does
paper::cubic_pieces). The walk takes them, and every writer draws them with the cubics it already writes.paper::cubicshelper.Pictures
No command on
drawingsputs these curves on a sheet yet. A view's round edges reach the sheet as short lines from the mesh, and drawing sketches (W38a) will be the first to bring ellipses and splines. So these pictures come from the SVG writer itself, the same path a sheet export takes. The test sheet is a plain A4 sheet with a border, a full ellipse made of four quarter conics (120 x 70 mm), a hyperbola arc (a conic of weight 2) and a Bézier wave of degree 5.Before, on
drawingsd5fd14135: the writer refuses the whole sheet:paper scene: not supported yet: ellipses, hyperbolas and Béziers above degree 3 on paper (#4890, A3b)After, on
4a29e9034(this commit before the moves): the sheet is written, and each curve is drawn as SVG cubics. The SVG was rendered to PNG in Chrome.Tests
On this head
7b21de6a7overdrawingscca77b176, local, Windows,--profile ci:cargo fmt --check,xtask listsandxtask i18n --checkpass;-D warningsovergeom,doc,io,engineandui-egui, all targets, passes;geom(379) andio(222),engine's drawing, paper and product tests (233) andsketch's paper and font tests (78): 912 passed, 0 failed.Planted faults, on this commit over
49a3ba1c0(the same code; the moves since changed only other lines): 7 faults, planted afresh for this run, all caught by a test, then the clean run passes. The first run missed one: the walk askingcubic_piecesfor a coarser error thanCURVE_ERROR_MM. A new check inslivers_and_radii_are_in_the_grids_own_stepsnow catches it. It flattens the walked ellipse and checks that every point is within the error of the true ellipse.No full gate on this head.
What these moves changed:
drawingsmoved fromd5fd14135tocca77b176(#9254, #10713, #5349, #10515, #7745, #10516, #11350, #11047, #9708, #11352, #7430, #10969 with #9833 and #9840, #10926). The conflicts were only lines side by side: the report's newdashes_snappedfield besidecurve_cubics, theclipmodule besidecubic_pieces, and the grid's imports.what_cannot_be_drawn_is_refused's note now says an ellipse draws.Integration status
Draft. #4891 stays the claim for #4890.