summaryrefslogtreecommitdiff
path: root/gerber/primitives.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2015-12-30 18:44:07 +0800
committerGarret Fick <garret@ficksworkshop.com>2015-12-30 18:44:07 +0800
commitf61eee807f87c329f6f88645ecdb48f01b887c52 (patch)
tree9c1422fac612c4bca82968c278540875ae9307e2 /gerber/primitives.py
parentff1ad704d5bb7814fdaebc156b727ec3c5f2d1a8 (diff)
downloadgerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.tar.gz
gerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.tar.bz2
gerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.zip
Render polygon flashes
Diffstat (limited to 'gerber/primitives.py')
-rw-r--r--gerber/primitives.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 86fd322..b0e17e9 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -17,7 +17,7 @@
import math
from operator import add, sub
-from .utils import validate_coordinates, inch, metric
+from .utils import validate_coordinates, inch, metric, rotate_point
from jsonpickle.util import PRIMITIVES
@@ -683,6 +683,7 @@ class Obround(Primitive):
class Polygon(Primitive):
"""
+ Polygon flash defined by a set number of sized.
"""
def __init__(self, position, sides, radius, **kwargs):
super(Polygon, self).__init__(**kwargs)
@@ -706,6 +707,18 @@ class Polygon(Primitive):
def offset(self, x_offset=0, y_offset=0):
self.position = tuple(map(add, self.position, (x_offset, y_offset)))
+
+ @property
+ def vertices(self):
+
+ offset = math.degrees(self.rotation)
+ da = 360.0 / self.sides
+
+ points = []
+ for i in xrange(self.sides):
+ points.append(rotate_point((self.position[0] + self.radius, self.position[1]), offset + da * i, self.position))
+
+ return points
class AMGroup(Primitive):
"""