ThorVG v1.1
Loading...
Searching...
No Matches
Scene

A class to composite children paints. More...

#include <thorvg.h>

Inheritance diagram for Scene:
Collaboration diagram for Scene:

Public Member Functions

Result add (Paint *target, Paint *at=nullptr) noexcept
 Adds a paint object to the scene.
 
const std::list< Paint * > & paints () const noexcept
 Returns the list of paints currently held by the Scene.
 
Result remove (Paint *paint=nullptr) noexcept
 Removes a paint object or all paint objects from the scene.
 
Result add (SceneEffect effect,...) noexcept
 Add a post-processing effect to the scene.
 
Type type () const noexcept override
 Returns the ID value of this class.
 
- Public Member Functions inherited from Paint
const Paintparent () const noexcept
 Retrieves the parent paint object.
 
Result visible (bool on) noexcept
 Sets the visibility of the Paint object.
 
Result rotate (float degree) noexcept
 Sets the angle by which the object is rotated.
 
Result scale (float factor) noexcept
 Sets the scale value of the object.
 
Result translate (float x, float y) noexcept
 Sets the values by which the object is moved in a two-dimensional space.
 
Result transform (const Matrix &m) noexcept
 Sets the matrix of the affine transformation for the object.
 
Matrixtransform () noexcept
 Gets the matrix of the affine transformation of the object.
 
Result opacity (uint8_t o) noexcept
 Sets the opacity of the object.
 
Result mask (Paint *target, MaskMethod method) noexcept
 Sets the masking target object and the masking method.
 
Result clip (Shape *clipper) noexcept
 Clip the drawing region of the paint object.
 
Result blend (BlendMethod method) noexcept
 Sets the blending method for the paint object.
 
Result bounds (Point *pt4) noexcept
 Retrieves the object-oriented bounding box (OBB) of the paint object in canvas space.
 
Result bounds (float *x, float *y, float *w, float *h) noexcept
 Retrieves the axis-aligned bounding box (AABB) of the paint object in canvas space.
 
TVG_DEPRECATED bool intersects (int32_t x, int32_t y, int32_t w=1, int32_t h=1) noexcept
 
bool intersects (int32_t x, int32_t y, int32_t w, int32_t h, bool visibleOnly) noexcept
 Checks whether a given region intersects the filled area of the paint.
 
Paintduplicate () const noexcept
 Duplicates the object.
 
uint8_t opacity () const noexcept
 Gets the opacity value of the object.
 
MaskMethod mask (const Paint **target) const noexcept
 Gets the masking target object and the masking method.
 
Shapeclip () const noexcept
 Get the clipper shape of the paint object.
 
bool visible () const noexcept
 Gets the current visibility status of the Paint object.
 
uint16_t ref () noexcept
 Increment the reference count for the Paint instance.
 
uint16_t unref (bool free=true) noexcept
 Decrement the reference count for the Paint instance.
 
uint16_t refCnt () const noexcept
 Retrieve the current reference count of the Paint instance.
 

Static Public Member Functions

static Scenegen () noexcept
 Creates a new Scene object.
 
- Static Public Member Functions inherited from Paint
static void rel (Paint *paint) noexcept
 Safely releases a Paint object.
 

Additional Inherited Members

- Public Attributes inherited from Paint
uint32_t id = 0
 Unique ID of this instance.
 

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.

Warning
This class is not designed for inheritance.

Member Function Documentation

◆ add() [1/2]

Result add ( Paint target,
Paint at = nullptr 
)
noexcept

Adds a paint object to the scene.

Appends a paint object to the scene. If the optional at parameter is provided, the paint object is inserted immediately before the specified paint in the scene. If at is nullptr, the paint object is appended to the end of the scene.

Parameters
[in]targetA pointer to the Paint object to be added to the scene. This parameter must not be nullptr.
[in]atA pointer to an existing Paint object in the scene before which target will be inserted. If nullptr, target is appended to the end of the scene. The default value is nullptr.
Note
Ownership of the target object is transferred to the scene upon successful addition. To retain ownership, call Paint::ref() before adding it to the scene.
The rendering order of paint objects follows their order in the scene. If layering is required, ensure the paints are added in the desired order.
See also
Scene::paints()
Scene::remove()
Paint::ref()
Since
1.0

◆ add() [2/2]

Result add ( SceneEffect  effect,
  ... 
)
noexcept

Add a post-processing effect to the scene.

Adds a post-processing effect to the scene's effect pipeline, which is applied after the scene has been rendered. Effects are applied cumulatively and in the order they are added. Calling this function multiple times will chain multiple effects sequentially.

Certain effects may be used to modify the pipeline behavior itself. For example, SceneEffect::Clear removes all previously added effects.

Parameters
[in]effectThe scene effect to add. Available effects are defined in the SceneEffect enum.
[in]...Additional variadic parameters required for certain effects (e.g., sigma and direction for GaussianBlur).
Note
The caller must provide the correct parameters for the selected effect. Supplying incorrect or insufficient arguments results in undefined behavior.
Since
1.0

◆ gen()

static Scene * gen ( )
staticnoexcept

Creates a new Scene object.

This function allocates and returns a new Scene instance. To properly destroy the Scene object, use Paint::rel().

Returns
A pointer to the newly created Scene object.
See also
Paint::rel()

◆ paints()

const std::list< Paint * > & paints ( ) const
noexcept

Returns the list of paints currently held by the Scene.

This function provides a list of paint nodes, allowing users to access scene-graph information.

See also
Scene::add()
Scene::remove()
Warning
This is read-only. Do not modify the list.
Since
1.0

◆ remove()

Result remove ( Paint paint = nullptr)
noexcept

Removes a paint object or all paint objects from the scene.

This function removes a specified paint object from the scene. If no paint object is specified (i.e., the default nullptr is used), the function performs to clear all paints from the scene.

Parameters
[in]paintA pointer to the Paint object to be removed from the scene. If nullptr, remove all the paints from the scene.
See also
Scene::add()
Scene::paints()
Since
1.0

◆ type()

Type type ( ) const
overridevirtualnoexcept

Returns the ID value of this class.

This method can be used to check the current concrete instance type.

Returns
The class type ID of the Scene instance.
Since
1.0

Implements Paint.