Support image.bgcolor to enable adapting to image colors

This commit is contained in:
KV 2021-02-20 01:31:07 +01:00 committed by Daniel Rojas
parent 45d7d03fe0
commit 324508a8ee
3 changed files with 5 additions and 2 deletions

View File

@ -424,6 +424,7 @@ image:
src: <path> # path to the image file
# optional parameters:
caption: <str> # text to display below the image
bgcolor: <color> # Background color of entry in diagram component box
width: <int> # range: 1~65535; unit: points
height: <int> # range: 1~65535; unit: points
# if only one dimension (width/height) is specified, the image is scaled proportionally.

View File

@ -75,6 +75,7 @@ class Image:
width: Optional[int] = None
height: Optional[int] = None
fixedsize: Optional[bool] = None
bgcolor: Optional[Color] = None
# Contents of the text cell <td> just below the image cell:
caption: Optional[MultilineHypertext] = None
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html

View File

@ -59,11 +59,12 @@ def html_image(image):
<td{html}</td>
</tr></table>
'''
return f'''<tdX{' sides="TLR"' if image.caption else ''}{html}'''
return f'''<tdX{' sides="TLR"' if image.caption else ''}{html_bgcolor_attr(image.bgcolor)}{html}'''
def html_caption(image):
from wireviz.DataClasses import Image
return f'<tdX sides="BLR">{html_line_breaks(image.caption)}' if image and image.caption else None
return (f'<tdX sides="BLR"{html_bgcolor_attr(image.bgcolor)}>{html_line_breaks(image.caption)}'
if image and image.caption else None)
def html_size_attr(image):
from wireviz.DataClasses import Image