From 3dc2a55f812ea821e06553fc3cfb414f129e0cff Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 6 Aug 2020 19:17:54 +0200 Subject: [PATCH] Add an image_scale attribute to both Connectors and Cables It specifies how an image will use any extra space available in its cell. Allowed values are one of these strings: - FALSE : keep image its natural size. (Default) - TRUE : scale image uniformly to fit. - WIDTH : expand image width to fill. - HEIGHT : expand image height to fill. - BOTH : expand both image width and height to fill. The value is sent to Graphviz as a scale attribute to the tag. Note that there is normally no extra height in the image cell. --- src/wireviz/DataClasses.py | 2 ++ src/wireviz/wv_helper.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 1a113c1..89bff69 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -19,6 +19,7 @@ class Connector: subtype: Optional[str] = None pincount: Optional[int] = None image: Optional[str] = None + image_scale: Optional[str] = "FALSE" caption: Optional[str] = None notes: Optional[str] = None pinlabels: List[Any] = field(default_factory=list) @@ -94,6 +95,7 @@ class Cable: wirecount: Optional[int] = None shield: bool = False image: Optional[str] = None + image_scale: Optional[str] = "FALSE" caption: Optional[str] = None notes: Optional[str] = None colors: List[Any] = field(default_factory=list) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index e185829..a91737e 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -56,7 +56,9 @@ def nested_html_table(rows): return html def html_image(node): - return f'''''' if node.image else None + if not node.image: + return None + return f'''''' def html_caption(node): return f'''{html_line_breaks(node.caption)}''' if node.caption else None