SVGCanvas

class SVGCanvas

Methods

Make

Returns a new canvas that will generate SVG commands from its draw calls, and send them to the provided stream. Ownership of the stream is not transfered, and it must remain valid for the lifetime of the returned canvas::.

__init__

Attributes

kConvertTextToPaths_Flag

kNoPrettyXML_Flag

Methods

static SVGCanvas.Make(bounds: skia.Rect, stream: skia.WStream, flags: int = 0) skia.Canvas

Returns a new canvas that will generate SVG commands from its draw calls, and send them to the provided stream. Ownership of the stream is not transfered, and it must remain valid for the lifetime of the returned canvas:

stream = skia.FILEWStream('output.svg')
canvas = skia.SVGCanvas.Make((640, 480), stream)
draw(canvas)
# Make sure to delete the canvas before the stream goes out of scope
del canvas
stream.flush()

The canvas may buffer some drawing calls, so the output is not guaranteed to be valid or complete until the canvas instance is deleted.

The ‘bounds’ parameter defines an initial SVG viewport (viewBox attribute on the root SVG element).

SVGCanvas.__init__(*args, **kwargs)

Attributes

SVGCanvas.kConvertTextToPaths_Flag = 1
SVGCanvas.kNoPrettyXML_Flag = 2