Support image.bgcolor to enable adapting to image colors
This commit is contained in:
parent
45d7d03fe0
commit
324508a8ee
@ -424,6 +424,7 @@ image:
|
|||||||
src: <path> # path to the image file
|
src: <path> # path to the image file
|
||||||
# optional parameters:
|
# optional parameters:
|
||||||
caption: <str> # text to display below the image
|
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
|
width: <int> # range: 1~65535; unit: points
|
||||||
height: <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.
|
# if only one dimension (width/height) is specified, the image is scaled proportionally.
|
||||||
|
|||||||
@ -75,6 +75,7 @@ class Image:
|
|||||||
width: Optional[int] = None
|
width: Optional[int] = None
|
||||||
height: Optional[int] = None
|
height: Optional[int] = None
|
||||||
fixedsize: Optional[bool] = None
|
fixedsize: Optional[bool] = None
|
||||||
|
bgcolor: Optional[Color] = None
|
||||||
# Contents of the text cell <td> just below the image cell:
|
# Contents of the text cell <td> just below the image cell:
|
||||||
caption: Optional[MultilineHypertext] = None
|
caption: Optional[MultilineHypertext] = None
|
||||||
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
||||||
|
|||||||
@ -59,11 +59,12 @@ def html_image(image):
|
|||||||
<td{html}</td>
|
<td{html}</td>
|
||||||
</tr></table>
|
</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):
|
def html_caption(image):
|
||||||
from wireviz.DataClasses import 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):
|
def html_size_attr(image):
|
||||||
from wireviz.DataClasses import Image
|
from wireviz.DataClasses import Image
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user