fix: GDK rounding for all shape primitives (#167)#422
Draft
rampageservices wants to merge 1 commit intogerbv:developfrom
Draft
fix: GDK rounding for all shape primitives (#167)#422rampageservices wants to merge 1 commit intogerbv:developfrom
rampageservices wants to merge 1 commit intogerbv:developfrom
Conversation
Replace integer-truncating division (/ 2, >> 1) with round(... / 2.0) when computing top-left coordinates for circles, macro primitives (prim1, prim6, prim7), rectangles, and ovals in the GDK renderer. Integer truncation causes off-by-one positioning of concentric apertures (e.g. pad + hole) at low zoom levels, making them appear misaligned. This extends the fix from PR gerbv#173 (which addressed arcs only) to all remaining shape primitives. Fixes gerbv#167
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
Extends the fix from PR #173 (which corrected arc bounding-box rounding) to all remaining shape primitives in the GDK renderer:
gerbv_gdk_draw_circle—x - dia / 2→round(x - dia / 2.0)gerbv_gdk_draw_prim1(macro circle) — same patterngerbv_gdk_draw_prim6(moiré) — inlinegdk_draw_arccallgerbv_gdk_draw_prim7(thermal) — inlinegdk_draw_arccallgerbv_gdk_draw_rectangle—>> 1→round(... / 2.0)gerbv_gdk_draw_oval—>> 1→round(... / 2.0)Integer division (
/ 2or>> 1) truncates toward zero, causing the bounding-box top-left corner to be off by one pixel for odd-valued dimensions. This makes concentric apertures (e.g. a pad with a drilled hole) appear misaligned at low zoom levels when using the GDK fast renderer.Using
round(... / 2.0)(which maps toceil()via the local macro) matches the fix already applied togerbv_gdk_draw_arcin #173.Fixes #167
Test plan
cmake --buildcompletes without warningsctestregression suite: same 11 pre-existing pixel-mismatch failures on bothdevelopand this branch (no new failures)