我在我的 Python 代码中使用 svgwrite 模块,我想设置背景颜色。到目前为止,我还没有找到任何东西。有没有办法做到这一点?
我希望在初始化过程中有所收获:
import svgwrite
canvas = svgwrite.drawing.Drawing(fill="#225566") # or background="#225566", or sth similar
canvas.save('image.png')
或者我可能会在整个地方绘制矩形,但这很奇怪。
It seems that svg itself does not define how to set the background colour. For svgwrite I use this:
svg_size_width = 900
svg_size_height = 4500
dwg = svgwrite.Drawing(name, (svg_size_width, svg_size_height), debug=True)
dwg.add(dwg.rect(insert=(0, 0), size=('100%', '100%'), rx=None, ry=None, fill='rgb(50,50,50)'))
dwg.save()