Home:ALL Converter>svgwrite: how to use Transform mixin

svgwrite: how to use Transform mixin

Ask Time:2022-09-03T22:01:48         Author:kyuden

Json Formatter

I want to transform a gradient to a certain degree.

# I want to do something like this

transform = svgwrite.mixins.Transform()
transform = transform.rotate(angle="138")
vert_grad = svgwrite.gradients.LinearGradient(start=(0, 0), end=(0,1), id="vert_lin_grad")
vert_grad.add_stop_color(offset='0%', color='blue', opacity=None)
vert_grad.add_stop_color(offset='50%', color='green', opacity=None)
vert_grad.add_stop_color(offset='100%', color='yellow', opacity=None)
dwg.defs.add(vert_grad)

The documentation tells me to use the Transform mixin: https://svgwrite.readthedocs.io/en/latest/classes/gradients.html#svg-attributes

But I'm not familiar with using mixins in python, and the above code gives me this error:

'Transform' object has no attribute 'attribs'

I have also been unable to find examples with SVG transform.

How do I use the Transform mixin?

Author:kyuden,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73592816/svgwrite-how-to-use-transform-mixin
yy