Skip to content

Commit

Permalink
Support image.bgcolor to enable adapting to image colors
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Sep 24, 2021
1 parent 15e5189 commit 9d64194
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/wireviz/wv_gv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d64194

Please sign in to comment.