summaryrefslogtreecommitdiff
path: root/gerbonara/aperture_macros/primitive.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-18 12:26:03 +0200
committerjaseg <git@jaseg.de>2023-04-19 00:51:27 +0200
commit2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6 (patch)
treedd588a4beff48425d5723f767a25e51d28e4500f /gerbonara/aperture_macros/primitive.py
parent263033c9bdecf8c82027f6475c863d818f499914 (diff)
downloadgerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.tar.gz
gerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.tar.bz2
gerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.zip
Basic KiCad footprint rendering works
Diffstat (limited to 'gerbonara/aperture_macros/primitive.py')
-rw-r--r--gerbonara/aperture_macros/primitive.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/gerbonara/aperture_macros/primitive.py b/gerbonara/aperture_macros/primitive.py
index f9b5a78..5b93971 100644
--- a/gerbonara/aperture_macros/primitive.py
+++ b/gerbonara/aperture_macros/primitive.py
@@ -11,6 +11,7 @@ import math
from .expression import Expression, UnitExpression, ConstantExpression, expr
from .. import graphic_primitives as gp
+from .. import graphic_objects as go
def point_distance(a, b):
@@ -18,8 +19,13 @@ def point_distance(a, b):
x2, y2 = b
return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
+
def deg_to_rad(a):
- return (a / 180) * math.pi
+ return a * (math.pi / 180)
+
+def rad_to_deg(a):
+ return a * (180 / math.pi)
+
class Primitive:
def __init__(self, unit, args):
@@ -240,7 +246,7 @@ class Outline(Primitive):
self.exposure = args.pop(0)
# length arg must not contain variables (that would not make sense)
- length_arg = args.pop(0).calculate()
+ length_arg = (args.pop(0) * ConstantExpression(1)).calculate()
if length_arg != len(args)//2-1:
raise ValueError(f'Invalid aperture macro outline primitive, given size {length_arg} does not match length of coordinate list({len(args)//2-1}).')
@@ -290,6 +296,7 @@ class Comment:
def scale(self, scale):
pass
+
PRIMITIVE_CLASSES = {
**{cls.code: cls for cls in [
Comment,