Support mesh gradients
cairosvg version: 2.4.2
$ cairosvg -f png mesh-gradient-practice.svg --output test.png
Traceback (most recent call last):
File "/home/sonri/.local/bin/cairosvg", line 8, in <module>
sys.exit(main())
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/__main__.py", line 83, in main
SURFACES[output_format.upper()].convert(**kwargs)
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/surface.py", line 146, in convert
instance = cls(
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/surface.py", line 212, in __init__
self.draw(tree)
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/surface.py", line 449, in draw
self.draw(child)
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/surface.py", line 449, in draw
self.draw(child)
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/surface.py", line 417, in draw
if not gradient_or_pattern(self, node, paint_source):
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/defs.py", line 90, in gradient_or_pattern
return draw_gradient(surface, node, name)
File "/home/sonri/.local/lib/python3.8/site-packages/cairosvg/defs.py", line 212, in draw_gradient
surface, gradient_node.get('gradientTransform'), gradient_pattern)
UnboundLocalError: local variable 'gradient_pattern' referenced before
Thanks for the bug report.
This problem happens because mesh gradients are not supported (it’s an SVG 2.0 feature). We can at least fix the crash, but supporting mesh gradients is a bit harder :wink:.
It souldn’t crash anymore!
Thanks, I appreciate it. Should I close this or leave the issue up as sort of a feature request? Whichever is more appropriate is fine with me.
Thanks, I appreciate it.
:heart:
Should I close this or leave the issue up as sort of a feature request? Whichever is more appropriate is fine with me.
We can keep it open as a feature request.