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 <img> tag. Note that there is normally no extra height in the image cell.
This commit is contained in:
parent
06e6c49aa9
commit
3dc2a55f81
@ -19,6 +19,7 @@ class Connector:
|
|||||||
subtype: Optional[str] = None
|
subtype: Optional[str] = None
|
||||||
pincount: Optional[int] = None
|
pincount: Optional[int] = None
|
||||||
image: Optional[str] = None
|
image: Optional[str] = None
|
||||||
|
image_scale: Optional[str] = "FALSE"
|
||||||
caption: Optional[str] = None
|
caption: Optional[str] = None
|
||||||
notes: Optional[str] = None
|
notes: Optional[str] = None
|
||||||
pinlabels: List[Any] = field(default_factory=list)
|
pinlabels: List[Any] = field(default_factory=list)
|
||||||
@ -94,6 +95,7 @@ class Cable:
|
|||||||
wirecount: Optional[int] = None
|
wirecount: Optional[int] = None
|
||||||
shield: bool = False
|
shield: bool = False
|
||||||
image: Optional[str] = None
|
image: Optional[str] = None
|
||||||
|
image_scale: Optional[str] = "FALSE"
|
||||||
caption: Optional[str] = None
|
caption: Optional[str] = None
|
||||||
notes: Optional[str] = None
|
notes: Optional[str] = None
|
||||||
colors: List[Any] = field(default_factory=list)
|
colors: List[Any] = field(default_factory=list)
|
||||||
|
|||||||
@ -56,7 +56,9 @@ def nested_html_table(rows):
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
def html_image(node):
|
def html_image(node):
|
||||||
return f'''<tdX{' sides="TLR"' if node.caption else ''}><img src="{node.image}"/>''' if node.image else None
|
if not node.image:
|
||||||
|
return None
|
||||||
|
return f'''<tdX{' sides="TLR"' if node.caption else ''}><img scale="{node.image_scale}" src="{node.image}"/>'''
|
||||||
|
|
||||||
def html_caption(node):
|
def html_caption(node):
|
||||||
return f'''<tdX{' sides="LRB"' if node.image else ''}>{html_line_breaks(node.caption)}''' if node.caption else None
|
return f'''<tdX{' sides="LRB"' if node.image else ''}>{html_line_breaks(node.caption)}''' if node.caption else None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user