summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/base_types.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/base_types.py
parent9624e46147755d221c8e7cf519e9ecd416381857 (diff)
downloadgerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.gz
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.bz2
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.zip
Fix failing test cases
Diffstat (limited to 'gerbonara/cad/kicad/base_types.py')
-rw-r--r--gerbonara/cad/kicad/base_types.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/gerbonara/cad/kicad/base_types.py b/gerbonara/cad/kicad/base_types.py
index 32717fb..1161996 100644
--- a/gerbonara/cad/kicad/base_types.py
+++ b/gerbonara/cad/kicad/base_types.py
@@ -97,7 +97,8 @@ class Stroke:
class Dasher:
def __init__(self, obj):
if obj.stroke:
- w, t = obj.stroke.width or 0.254, obj.stroke.type
+ w = obj.stroke.width if obj.stroke.width is not None else 0.254
+ t = obj.stroke.type
else:
w = obj.width or 0
t = Atom.solid
@@ -210,6 +211,20 @@ class XYCoord:
else:
self.x, self.y = x, y
+ def __iter__(self):
+ return iter((self.x, self.y))
+
+ def __getitem__(self, index):
+ return (self.x, self.y)[index]
+
+ def __setitem__(self, index, value):
+ if index == 0:
+ self.x = value
+ elif index == 1:
+ self.y = value
+ else:
+ raise IndexError(f'Invalid 2D point coordinate index {index}')
+
def within_distance(self, x, y, dist):
return math.dist((x, y), (self.x, self.y)) < dist