SVGRenderer

Qualified name: manimpango.renderer.SVGRenderer

class SVGRenderer

SVGRenderer is a renderer which renders the Layout to an SVG file. Note that unlike other renderers the file_name is a required parameter.

The file_name is opened when the class is initialised and only closed when the renderer is destroyed.

Parameters
  • width (float) – The width of the SVG.

  • height (float) – The height of the SVG.

  • layout (Layout) – The Layout that needs to be rendered.

  • file_name (str) – The path to SVG file.

Example

>>> import manimpango as mp
>>> a = mp.SVGRenderer(100, 100, mp.Layout('hello'), 'test.svg')
>>> a
<SVGRenderer file_name='test.svg' width=100.0 height=100.0 layout=<Layout text='hello' markup=None>
>>> a.render()
True
>>> a.save()
'test.svg'
Raises

Exception – Any error reported by cairo.

Methods

render

render() actually does the rendering.

save

This method save's the SVG file.

file_name

The file_name where the file is rendered onto

height

The height of the SVG.

layout

The Layout which is being rendered.

render()

render() actually does the rendering. Any error reported by Cairo is reported as an exception. If this method suceeds you can expect an valid SVG file at file_name.

Returns

True if the function worked, else False.

Return type

bool

save()

This method save’s the SVG file. Note that this method is provided for compatibility with other renderers and does nothing.

Parameters

file_name – The filename to save the file. Note that this is not used and instead only file_name is used

Returns

The filename of the rendered SVG file.

Return type

str

width

The width of the SVG.