diff options
author | jaseg <git@jaseg.de> | 2022-06-10 00:39:07 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-10 00:39:07 +0200 |
commit | 460ea625af5c1d9e243feaa49923f7b2c7db8837 (patch) | |
tree | 3d7e71e3015d0dd70c7d5f8478448a5cdd369d30 /gerbonara/graphic_primitives.py | |
parent | e422243a6e76d0b798ae8f175a717c193be4d22a (diff) | |
download | gerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.tar.gz gerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.tar.bz2 gerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.zip |
Fix merging, bounding boxes and svg precision
Diffstat (limited to 'gerbonara/graphic_primitives.py')
-rw-r--r-- | gerbonara/graphic_primitives.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gerbonara/graphic_primitives.py b/gerbonara/graphic_primitives.py index bfb1e89..7bbd3ff 100644 --- a/gerbonara/graphic_primitives.py +++ b/gerbonara/graphic_primitives.py @@ -23,6 +23,8 @@ from dataclasses import dataclass, KW_ONLY, replace from .utils import * +prec = lambda x: f'{x:.6}' + @dataclass class GraphicPrimitive: @@ -65,7 +67,7 @@ class Circle(GraphicPrimitive): def to_svg(self, fg='black', bg='white', tag=Tag): color = fg if self.polarity_dark else bg - return tag('circle', cx=self.x, cy=self.y, r=self.r, style=f'fill: {color}') + return tag('circle', cx=prec(self.x), cy=prec(self.y), r=prec(self.r), style=f'fill: {color}') @dataclass @@ -255,6 +257,6 @@ class Rectangle(GraphicPrimitive): def to_svg(self, fg='black', bg='white', tag=Tag): color = fg if self.polarity_dark else bg x, y = self.x - self.w/2, self.y - self.h/2 - return tag('rect', x=x, y=y, width=self.w, height=self.h, + return tag('rect', x=prec(x), y=prec(y), width=prec(self.w), height=prec(self.h), transform=svg_rotation(self.rotation, self.x, self.y), style=f'fill: {color}') |