Skip to content
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

Circular board outlines are not supported #3

Open
follower opened this issue Nov 18, 2017 · 0 comments
Open

Circular board outlines are not supported #3

follower opened this issue Nov 18, 2017 · 0 comments

Comments

@follower
Copy link
Contributor

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 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

led_spinner-Edge.Cuts.gbr.txt

I'll pop in a PR in with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant