Fix circle primitives in aperture macros ignoring rotation#286
Merged
spe-ciellt merged 2 commits intogerbv:developfrom Feb 27, 2026
Merged
Fix circle primitives in aperture macros ignoring rotation#286spe-ciellt merged 2 commits intogerbv:developfrom
spe-ciellt merged 2 commits intogerbv:developfrom
Conversation
The Gerber spec defines circle primitive (code 1) with 5 parameters: exposure, diameter, center_x, center_y, and rotation. gerbv only stored 4 parameters (nuf_parameters = 4), silently discarding the rotation. When a macro uses off-center circles with rotation, the centers must orbit around the origin, but gerbv rendered them at their unrotated positions. Changes: - Add CIRCLE_ROTATION to gerbv_aptype_macro_circle_index_t enum - Set nuf_parameters = 5 for circle primitives so rotation is stored - Cap memcpy to s->sp (actual stack depth) so macros with only 4 circle parameters don't read stale stack data as rotation; omitted trailing parameters default to 0 from the memset - Apply cairo_rotate before cairo_translate when rendering circles, matching the existing pattern used by LINE20/LINE21 primitives - Rotate center coordinates in bounding box calculation so the viewport auto-fit includes all rotated circle positions - Accumulate external rotation in image merge (step-and-repeat) - Export the 5th parameter (rotation) in RS-274X output The rotation is in degrees and is not a spatial dimension, so it is intentionally excluded from the mm-to-inches unit conversion block. Fixes gerbv#254
d62decd to
e7b36bb
Compare
Contributor
|
Thank you for this patch. If this is good enough I apply it else I will leave comments. |
Contributor
|
Code: The implementation is comprehensive and internally consistent:
Before fix: Four off-center circles at 0°/90°/180°/270° all render at the 0° position (overlapping). Tests: New test |
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.
Summary
CIRCLE_ROTATIONto the circle parameter enum and stores the 5th parameter (nuf_parameters = 5)cairo_rotate()beforecairo_translate()when rendering circles, so off-center circles orbit around the origin — matching the existing pattern used by LINE20/LINE21memcpyto actual stack depth (s->sp) so macros with only 4 circle parameters (rotation omitted) don't read stale stack data; omitted trailing parameters default to 0 from the pre-existingmemsetThe rotation is in degrees, not a spatial dimension, so it is intentionally excluded from the mm-to-inches unit conversion block.
Files changed
src/gerbv.hCIRCLE_ROTATIONto enumsrc/gerber.cnuf_parameters = 5, cap tos->sp, rotate center in bboxsrc/draw.csrc/gerb_image.csrc/export-rs274x.cTest plan
test-amacro-circle-rotation.gbx— single macro with 4 off-center circles at 0°/90°/180°/270° renders as a cross pattern (without fix, all 4 overlap at the 0° position)example_am_test(uses1,1,$1,0,0*with no rotation param) still renders correctly — thes->spguard ensures omitted rotation defaults to 0Fixes #254