summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/graphical_primitives.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-10-26 23:53:23 +0200
committerjaseg <git@jaseg.de>2023-10-26 23:53:23 +0200
commit36da1fd68bcfb44957d370584231545cee0b2e20 (patch)
tree7bf1730a71392ab3de33010a56edf3ce0a2a09e6 /gerbonara/cad/kicad/graphical_primitives.py
parent9624e46147755d221c8e7cf519e9ecd416381857 (diff)
downloadgerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.gz
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.bz2
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.zip
Fix failing test cases
Diffstat (limited to 'gerbonara/cad/kicad/graphical_primitives.py')
-rw-r--r--gerbonara/cad/kicad/graphical_primitives.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/gerbonara/cad/kicad/graphical_primitives.py b/gerbonara/cad/kicad/graphical_primitives.py
index a2393d2..94a61a4 100644
--- a/gerbonara/cad/kicad/graphical_primitives.py
+++ b/gerbonara/cad/kicad/graphical_primitives.py
@@ -203,10 +203,10 @@ class Arc:
return
aperture = ap.CircleAperture(self.width, unit=MM)
- cx, cy = self.mid.x, self.mid.y
x1, y1 = self.start.x, self.start.y
x2, y2 = self.end.x, self.end.y
- yield go.Arc(x1, -y1, x2, -y2, cx-x1, -(cy-y1), aperture=aperture, clockwise=True, unit=MM)
+ (cx, cy), _r = kicad_mid_to_center_arc(self.mid, self.start, self.end)
+ yield go.Arc(x1, -y1, x2, -y2, cx-x1, -(cy-y1), aperture=aperture, clockwise=False, unit=MM)
def offset(self, x=0, y=0):
self.start = self.start.with_offset(x, y)
@@ -224,7 +224,23 @@ class Polygon:
tstamp: Timestamp = None
def render(self, variables=None):
- reg = go.Region([(pt.x, -pt.y) for pt in self.pts.xy], unit=MM)
+ points = []
+ centers = []
+ for point_or_arc in self.pts:
+ if points:
+ centers.append((None, (None, None)))
+
+ if isinstance(point_or_arc, XYCoord):
+ points.append((point_or_arc.x, -point_or_arc.y))
+
+ else: # base_types.Arc
+ points.append((point_or_arc.start.x, -point_or_arc.start.y))
+ points.append((point_or_arc.end.x, -point_or_arc.end.y))
+ (cx, cy), _r = kicad_mid_to_center_arc(point_or_arc.mid, point_or_arc.start, point_or_arc.end)
+ centers.append((False, (cx, -cy)))
+
+ reg = go.Region(points, centers, unit=MM)
+ reg.close()
# FIXME stroke support
if self.width and self.width >= 0.005 or self.stroke.width and self.stroke.width > 0.005: