ThorVG  v0.5
Public Member Functions | Static Public Member Functions | List of all members
Scenefinal

A class to composite children paints. More...

Inheritance diagram for Scene:
Inheritance graph
[legend]

Public Member Functions

Result push (std::unique_ptr< Paint > paint) noexcept
 Passes drawing elements to the Scene using Paint objects. More...
 
Result reserve (uint32_t size) noexcept
 Sets the size of the container, where all the paints pushed into the Scene are stored. More...
 
Result clear (bool free=true) noexcept
 Sets the total number of the paints pushed into the scene to be zero. Depending on the value of the free argument, the paints are freed or not. More...
 
- Public Member Functions inherited from Paint
Result rotate (float degree) noexcept
 Sets the angle by which the object is rotated. More...
 
Result scale (float factor) noexcept
 Sets the scale value of the object. More...
 
Result translate (float x, float y) noexcept
 Sets the values by which the object is moved in a two-dimensional space. More...
 
Result transform (const Matrix &m) noexcept
 Sets the matrix of the affine transformation for the object. More...
 
Matrix transform () noexcept
 Gets the matrix of the affine transformation of the object. More...
 
Result opacity (uint8_t o) noexcept
 Sets the opacity of the object. More...
 
Result composite (std::unique_ptr< Paint > target, CompositeMethod method) noexcept
 Sets the composition target object and the composition method. More...
 
TVG_DEPRECATED Result bounds (float *x, float *y, float *w, float *h) const noexcept
 Gets the bounding box of the paint object before any transformation. More...
 
Result bounds (float *x, float *y, float *w, float *h, bool transformed) const noexcept
 Gets the axis-aligned bounding box of the paint object. More...
 
Paintduplicate () const noexcept
 Duplicates the object. More...
 
uint8_t opacity () const noexcept
 Gets the opacity value of the object. More...
 
CompositeMethod composite (const Paint **target) const noexcept
 Gets the composition target object and the composition method. More...
 

Static Public Member Functions

static std::unique_ptr< Scenegen () noexcept
 Creates a new Scene object. More...
 

Detailed Description

A class to composite children paints.

As the traditional graphics rendering method, TVG also enables scene-graph mechanism. This feature supports an array function for managing the multiple paints as one group paint.

As a group, the scene can be transformed, made translucent and composited with other target paints, its children will be affected by the scene world.

Member Function Documentation

◆ clear()

Result clear ( bool  free = true)
noexcept

Sets the total number of the paints pushed into the scene to be zero. Depending on the value of the free argument, the paints are freed or not.

Parameters
[in]freeIf true, the memory occupied by paints is deallocated, otherwise it is not.
Returns
Result::Success when succeed
Warning
If you don't free the paints they become dangled. They are supposed to be reused, otherwise you are responsible for their lives. Thus please use the free argument only when you know how it works, otherwise it's not recommended.
Please do not use it, this API is not official one. It could be modified in the next version.
Since
0.2

◆ gen()

static std::unique_ptr<Scene> gen ( )
staticnoexcept

Creates a new Scene object.

Returns
A new Scene object.

◆ push()

Result push ( std::unique_ptr< Paint paint)
noexcept

Passes drawing elements to the Scene using Paint objects.

Only pushed paints in the scene will be drawing targets. They are retained by the scene until you call Scene::clear(). If you know the number of the pushed objects in the advance, please call Scene::reserve().

Parameters
[in]paintA Paint object to be drawn.
Returns
Result::Success when succeed, Result::MemoryCorruption otherwise.
Note
The rendering order of the paints is the same as the order as they were pushed. Consider sorting the paints before pushing them if you intend to use layering.
See also
Scene::reserve()

◆ reserve()

Result reserve ( uint32_t  size)
noexcept

Sets the size of the container, where all the paints pushed into the Scene are stored.

If the number of objects pushed into the scene is known in advance, calling the function prevents multiple memory reallocation, thus improving the performance.

Parameters
[in]sizeThe number of objects for which the memory is to be reserved.
Returns
Result::Success when succeed.