ImageRenderer¶
Qualified name: manimpango.renderer.ImageRenderer
- class ImageRenderer¶
ImageRenderer
is a renderer which renders theLayout
to an image buffer. You can directly use the buffer or else you can save it to a file, as a png file, using thesave()
method.The
file_name
is optional, if you don’t provide it then you can use theget_buffer()
method to get the buffer.- Parameters
Example
>>> import manimpango as mp >>> a = mp.ImageRenderer(100, 100, mp.Layout('hello'), 'test.png') >>> a <ImageRenderer file_name='test.png' width=100.0 height=100.0 layout=<Layout text='hello' markup=None> >>> a.render() True >>> a.save() 'test.png'
- Raises
Exception – Any error reported by cairo.
Methods
This method returns the buffer of the image.
render()
actually does the rendering.This method is to save the image to an PNG image.
- file_name¶
The file_name where the file is rendered onto
- get_buffer()¶
This method returns the buffer of the image. This contains the image in the format of
ARGB32
.- Returns
The buffer of the image.
- Return type
- height¶
The height of the PNG.
- 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 image in the buffer.- Returns
True
if the function worked, elseFalse
.- Return type
- save()¶
This method is to save the image to an PNG image. Note that only PNG image are supported, if you need other formats, use external libraries such as Pillow.
- Parameters
file_name – The file_name to write the image to.
- Raises
ValueError – Raised when the file_name parameter is
None
.- Returns
The filepath to the saved file.
- Return type
- stride¶
The stride of the PNG.
- width¶
The width of the PNG.