ThorVG v1.0
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 push (Paint *target, Paint *at=nullptr) noexcept
 Inserts 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 push (SceneEffect effect,...) noexcept
 Apply 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.
 
bool intersects (int32_t x, int32_t y, int32_t w=1, int32_t h=1) 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

◆ 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::push()
Scene:remove()
Warning
This is read-only. Do not modify the list.
Since
1.0

◆ push() [1/2]

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

Inserts a paint object to the scene.

This function appends a paint object to the scene. If the optional at is provided, the new paint object will be inserted immediately before the specified paint object in the scene. If at is nullptr, the paint object will be added to the end of the scene.

Parameters
[in]targetA pointer to the Paint object to be added into the scene. This parameter must not be nullptr.
[in]atA pointer to an existing Paint object in the scene before which the new paint object will be added. If nullptr, the new paint object is added to the end of the scene. The default is nullptr.
Note
The ownership of the paint object is transferred to the scene upon addition.
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::paints()
Scene:remove()

◆ push() [2/2]

Result push ( SceneEffect  effect,
  ... 
)
noexcept

Apply a post-processing effect to the scene.

This function adds a specified effect—such as clearing all effects, applying a Gaussian blur, or adding a drop shadow—to the scene after rendering. Multiple effects can be applied in sequence by calling this function multiple times.

Parameters
[in]effectThe scene effect to apply. Options are defined in the SceneEffect enum. For example, use SceneEffect::GaussianBlur to apply a blur with specific parameters.
[in]...Additional variadic parameters required for certain effects (e.g., sigma and direction for GaussianBlur).
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::push()
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.