You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The result was two 78 x 78 pixel images, one filled with black, the other filled with white.
It wasn't immediately obvious that the issue was due to the circular board outline as the second board I tested with also had a circular outline. (What can I say, I like circles... :D )
Underlying issue
I eventually tracked the apparent underlying cause down to how the circular board outline is handled by draw_arc(). (I'm not 100% sure why draw_arc() is used rather than Circle etc but I didn't investigate further to understand it better. )
My understanding is that when the arc is a complete circle, the start_angle & end_angle variables both end up having the value 0.0 so the drawing of the outline is skipped entirely!
Potential solutions
I originally used this patch (but I've just realized there's a simpler option earlier in the method):
--- a/gerber2png.py+++ b/gerber2png.py@@ -339,6 +339,8 @@ class GerberData:
# Where r is the radius, cx,cy the origin, and a the angle from 0..2PI radians or 0..360 degrees.
if line.endswith("D01*"): # move with shutter OPEN
# make a path from lastPoint to x,y
+ if (start_angle == end_angle == 0):+ end_angle = DOUBLE_PI
angle = start_angle
while angle < end_angle:
xx = int( round(centerx + radius * math.cos(-angle)))
The simpler patch is to handle the issue where there's a similar check/adjustment already:
diff --git a/gerber2png.py b/gerber2png.py
index e743fd7..435c61e 100755
--- a/gerber2png.py+++ b/gerber2png.py@@ -326,7 +326,7 @@ class GerberData:
arc_resolution = 0.00175
# if not clockwise:
- if start_angle > end_angle:+ if start_angle >= end_angle:
end_angle += DOUBLE_PI
I initially tested
gerber2png.py
with a PCB that had a circular edge cuts like this one:The result was two 78 x 78 pixel images, one filled with black, the other filled with white.
It wasn't immediately obvious that the issue was due to the circular board outline as the second board I tested with also had a circular outline. (What can I say, I like circles... :D )
Underlying issue
I eventually tracked the apparent underlying cause down to how the circular board outline is handled by
draw_arc()
. (I'm not 100% sure whydraw_arc()
is used rather thanCircle
etc but I didn't investigate further to understand it better. )My understanding is that when the arc is a complete circle, the
start_angle
&end_angle
variables both end up having the value0.0
so the drawing of the outline is skipped entirely!Potential solutions
I originally used this patch (but I've just realized there's a simpler option earlier in the method):
The simpler patch is to handle the issue where there's a similar check/adjustment already:
led_spinner-Edge.Cuts.gbr.txt
I'll pop in a PR in with this change.
The text was updated successfully, but these errors were encountered: