From b5b3da860d293dc548fb66552dbb9d00f497f5fa Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Fri, 7 May 2021 03:28:22 +0300 Subject: [PATCH] Fix generation for single node. --- roentgen.py | 14 +++++++++++--- roentgen/point.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/roentgen.py b/roentgen.py index c45806a..20a7367 100644 --- a/roentgen.py +++ b/roentgen.py @@ -136,8 +136,16 @@ def draw_element(target: str, tags_description: str): icon, labels, tags, np.array((32, 32)), None, is_for_node=is_for_node, draw_outline=is_for_node ) - print(point.is_for_node) - svg = svgwrite.Drawing("test_icon.svg", (64, 64)) + border: int = 8 + icon_size: int = 16 + width: int = ( + border * 2 + (1 + max(2, len(icon.extra_icons) - 1)) * icon_size + ) + height: int = border * 2 + (1 + int(len(icon.extra_icons) / 3)) * icon_size + if len(labels): + height += 2 + 11 * len(labels) + point.point = np.array((width / 2, border + icon_size / 2)) + svg = svgwrite.Drawing("test_icon.svg", (width, height)) for style in scheme.get_style(tags, 18): style: LineStyle path = svg.path(d="M 0,0 L 64,0 L 64,64 L 0,64 L 0,0 Z") @@ -145,7 +153,7 @@ def draw_element(target: str, tags_description: str): svg.add(path) point.draw_main_shapes(svg) point.draw_extra_shapes(svg) - point.draw_texts(svg, None) + point.draw_texts(svg) svg.write(open("test_icon.svg", "w+")) diff --git a/roentgen/point.py b/roentgen/point.py index a8962e2..15940d6 100644 --- a/roentgen/point.py +++ b/roentgen/point.py @@ -149,7 +149,7 @@ class Point(Tagged): return True def draw_texts( - self, svg: svgwrite.Drawing, occupied: Optional[Occupied] + self, svg: svgwrite.Drawing, occupied: Optional[Occupied] = None ) -> None: """ Draw all labels.