thorvg_python.canvas.sw¶
Classes¶
SwCanvas API |
Module Contents¶
-
class thorvg_python.canvas.sw.SwCanvas(engine: thorvg_python.engine.Engine, op: thorvg_python.base.EngineOption =
EngineOption.DEFAULT, canvas: thorvg_python.base.CanvasPointer | None =None)¶ Bases:
thorvg_python.canvas.CanvasSwCanvas API
A module for rendering the graphical elements using the software engine.
- engine¶
- thorvg_lib¶
-
buffer_arr : ctypes.Array[ctypes.c_uint32] | None =
None¶
-
w : int | None =
None¶
-
h : int | None =
None¶
-
stride : int | None =
None¶
-
cs : thorvg_python.base.Colorspace | None =
None¶
-
_create(op: thorvg_python.base.EngineOption =
EngineOption.DEFAULT) thorvg_python.base.CanvasPointer¶ Creates a new Software Canvas object with optional rendering engine settings.
This method generates a software canvas instance that can be used for drawing vector graphics. It accepts an optional parameter
opto choose between different rendering engine behaviors.- Parameters:¶
- op : thorvg_python.engine.EngineOption¶
The rendering engine option.
- Returns:¶
A new CanvasPointer object.
- Return type:¶
Note
You need not call this method as it is auto called when initializing
SwCanvas().See also
EngineOption
-
set_target(w: int, h: int, stride: int | None =
None, cs: thorvg_python.base.Colorspace =Colorspace.ABGR8888) tuple[thorvg_python.base.Result, ctypes.Array[ctypes.c_uint32]]¶ Sets the buffer used in the rasterization process and defines the used colorspace.
For optimisation reasons TVG does not allocate memory for the output buffer on its own. The buffer of a desirable size should be allocated and owned by the caller.
w, h, stride, cs and buffer_arr will be stored in instance when calling this method.
- Parameters:¶
- Returns:¶
Result.INVALID_ARGUMENTS An invalid canvas or buffer pointer passed or one of the
stride,worhbeing zero.Result.INSUFFICIENT_CONDITION if the canvas is performing rendering. Please ensure the canvas is synced.
Result.NOT_SUPPORTED The software engine is not supported.
- Return type:¶
- Returns:¶
A pointer to the allocated memory block of the size
stridexh.- Return type:¶
ctypes.Array[ctypes.c_uint32]
Warning
Do not access
bufferduring Canvas_draw() - Canvas_sync(). It should not be accessed while the engine is writing on it.See also
Colorspace