diff options
author | Garret Fick <garret@ficksworkshop.com> | 2016-07-24 22:08:31 +0800 |
---|---|---|
committer | Garret Fick <garret@ficksworkshop.com> | 2016-07-24 22:08:31 +0800 |
commit | 965d3ce23b92f8aff1063debd6d3364de15791fe (patch) | |
tree | 304ac755578479554ed812da87c782e9f6772582 /gerber/primitives.py | |
parent | 7cd6acf12670f3773113f67ed2acb35cb21c32a0 (diff) | |
download | gerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.tar.gz gerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.tar.bz2 gerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.zip |
Add more tests for rendering to PNG. Start adding tests for rendering to Gerber format. Changed definition of no hole to use None instead of 0 so we can differentiate when writing to Gerber format. Makde polygon use hole diameter instead of hole radius to match other primitives
Diffstat (limited to 'gerber/primitives.py')
-rw-r--r-- | gerber/primitives.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/gerber/primitives.py b/gerber/primitives.py index b8ee344..f259eff 100644 --- a/gerber/primitives.py +++ b/gerber/primitives.py @@ -370,7 +370,7 @@ class Arc(Primitive): class Circle(Primitive):
"""
"""
- def __init__(self, position, diameter, hole_diameter = 0, **kwargs):
+ def __init__(self, position, diameter, hole_diameter = None, **kwargs):
super(Circle, self).__init__(**kwargs)
validate_coordinates(position)
self.position = position
@@ -388,7 +388,9 @@ class Circle(Primitive): @property
def hole_radius(self):
- return self.hole_diameter / 2.
+ if self.hole_diameter != None:
+ return self.hole_diameter / 2.
+ return None
@property
def bounding_box(self):
@@ -486,8 +488,10 @@ class Rectangle(Primitive): @property
def hole_radius(self):
- """The radius of the hole. If there is no hole, returns 0"""
- return self.hole_diameter / 2.
+ """The radius of the hole. If there is no hole, returns None"""
+ if self.hole_diameter != None:
+ return self.hole_diameter / 2.
+ return None
@property
def bounding_box(self):
@@ -691,8 +695,10 @@ class Obround(Primitive): @property
def hole_radius(self):
- """The radius of the hole. If there is no hole, returns 0"""
- return self.hole_diameter / 2.
+ """The radius of the hole. If there is no hole, returns None"""
+ if self.hole_diameter != None:
+ return self.hole_diameter / 2.
+ return None
@property
def orientation(self):
@@ -740,14 +746,14 @@ class Polygon(Primitive): """
Polygon flash defined by a set number of sides.
"""
- def __init__(self, position, sides, radius, hole_radius, **kwargs):
+ def __init__(self, position, sides, radius, hole_diameter, **kwargs):
super(Polygon, self).__init__(**kwargs)
validate_coordinates(position)
self.position = position
self.sides = sides
self.radius = radius
- self.hole_radius = hole_radius
- self._to_convert = ['position', 'radius']
+ self.hole_diameter = hole_diameter
+ self._to_convert = ['position', 'radius', 'hole_diameter']
@property
def flashed(self):
@@ -756,6 +762,12 @@ class Polygon(Primitive): @property
def diameter(self):
return self.radius * 2
+
+ @property
+ def hole_radius(self):
+ if self.hole_diameter != None:
+ return self.hole_diameter / 2.
+ return None
@property
def bounding_box(self):
|