-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PyGerber]: Macro elements come out upside down in SVG render #371
Comments
Hi Thanks for reporting the issue. |
The example gerber renders correctly with 3.0.0a4. |
Thanks for checking. |
Found that setting the flip_y argument in SVGRenderer2Hooks init() to False causes it to render correctly, albeit the entire image is upside-down. |
The image flip is caused by Y axis in SVG having opposite direction than in Gerber format, flip_y was introduced to counteract this problem. |
Ok so I think what's going on is that flipping isn't inherited for children of macro elements. That's why setting flip to true when the macro function makes a new frame partially fixes the issue. As for the offset issue afterwards I found it was always the height of the element's bounding box lower than it should be, so I changed it to not do that offset in macro frames, and that made it work. |
I appreciate your findings, could you submit a pull request so we can verify this fix against test suite? |
PyGerber Bug Report
Mandatory checks
Before opening this issue:
duplicate.
resolved or marked as won't fix.
known issue.
known issue.
#242
To Reproduce
Run below code with errtest-F_Paste.txt (note, wouldn't let me upload .gbr so I changed it to a .txt, just change it back)
Should result in
(Note: rounded rectangle macros generated by KiCad, not normal rectangles)
Expected behavior
Image should be this (from KiCad gerber viewer)
Also, output from raster renderer
Additional context
Initially thought the issue was inverted rotation, like with the rectangle issue, however it became clear its y axis inversion when looking at asymmetric elements (unfortunately I couldn't figure out how to make an original test file with such elements). I poked around trying to fix it myself for a bit, and I think the issue is somewhere around render_flash_macro in renderer2/svg.py. Changing
flip_y=False
(668 svg.py) to True sort of fixed the issue, but affected elements were misplaced vertically.Environment:
Please complete the following information:
Optional checks
of PyGerber for regression testing purposes.
an agreement described in first checkbox in this section.
an agreement described in first checkbox in this section.
The text was updated successfully, but these errors were encountered: