summaryrefslogtreecommitdiff
path: root/gerberex/statements.py
diff options
context:
space:
mode:
authoropiopan <opiopan@gmail.com>2019-03-23 21:59:13 +0900
committeropiopan <opiopan@gmail.com>2019-03-23 21:59:13 +0900
commit690df56bb71020901167605a87ec451081fa18d7 (patch)
treec1faba9ba0cb75d64d8353a94d87edbcbb8174c3 /gerberex/statements.py
parent9febca7da6a730b3b3ca3a54129a9f88e5c44d14 (diff)
downloadgerbonara-690df56bb71020901167605a87ec451081fa18d7.tar.gz
gerbonara-690df56bb71020901167605a87ec451081fa18d7.tar.bz2
gerbonara-690df56bb71020901167605a87ec451081fa18d7.zip
add rotation fuction
Diffstat (limited to 'gerberex/statements.py')
-rw-r--r--gerberex/statements.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/gerberex/statements.py b/gerberex/statements.py
index 77ca235..c41acb9 100644
--- a/gerberex/statements.py
+++ b/gerberex/statements.py
@@ -11,9 +11,41 @@ class AMParamStmtEx(AMParamStmt):
def from_stmt(cls, stmt):
return cls(stmt.param, stmt.name, stmt.macro)
+ @classmethod
+ def circle(cls, name):
+ return cls('AM', name, '1,1,$1,0,0,0*1,0,$2,0,0,0')
+
+ @classmethod
+ def rectangle(cls, name):
+ return cls('AM', name, '21,1,$1,$2,0,0,0*1,0,$3,0,0,0')
+
+ @classmethod
+ def landscape_obround(cls, name):
+ return cls(
+ 'AM', name,
+ '$4=$1-$2*'
+ '21,1,$1-$4,$2,0,0,0*'
+ '1,1,$4,$4/2,0,0*'
+ '1,1,$4,-$4/2,0,0*'
+ '1,0,$3,0,0,0')
+
+ @classmethod
+ def portrate_obround(cls, name):
+ return cls(
+ 'AM', name,
+ '$4=$2-$1*'
+ '21,1,$1,$2-$4,0,0,0*'
+ '1,1,$4,0,$4/2,0*'
+ '1,1,$4,0,-$4/2,0*'
+ '1,0,$3,0,0,0')
+
+ @classmethod
+ def polygon(cls, name):
+ return cls('AM', name, '5,1,$2,0,0,$1,$3*1,0,$4,0,0,0')
+
def __init__(self, param, name, macro):
super(AMParamStmtEx, self).__init__(param, name, macro)
- self.primitive_defs = to_primitive_defs(self.instructions)
+ self.primitive_defs = list(to_primitive_defs(self.instructions))
def to_inch(self):
if self.units == 'metric':
@@ -32,3 +64,7 @@ class AMParamStmtEx(AMParamStmt):
for p in self.primitive_defs:
yield p.to_gerber(settings)
return "%%AM%s*\n%s%%" % (self.name, '\n'.join(plist()))
+
+ def rotate(self, angle, center=None):
+ for primitive_def in self.primitive_defs:
+ primitive_def.rotate(angle, center)