The ID of this paint object. IDs are used to identify paint objects within a picture's scene tree. Assign a string to generate a hash ID from the name, or a number to set directly.
Gets the WASM pointer for this object Returns 0 if object has been disposed (error handled by global handler)
Check if this object has been disposed
Protected_Cleanup function to be implemented by subclasses
The WASM pointer to clean up
Translate the paint by (x, y)
Rotate the paint by angle (in degrees)
Scale the paint by factor
Set the blending method for this paint. Blending determines how this paint is combined with the content below it.
The blending method to use
The Paint instance for method chaining
Get or set the opacity (0 to 255)
When setting, returns the Paint instance for method chaining. When getting, returns the opacity value (0-255).
Get or set the opacity (0 to 255)
The opacity value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
When setting, returns the Paint instance for method chaining. When getting, returns the opacity value (0-255).
Get or set the visibility
Get or set the visibility
Applies a custom transformation matrix to the paint.
This method allows you to apply complex transformations that combine translation, rotation, scaling, and skewing in a single operation. The matrix is multiplied with any existing transformations.
A 3x3 transformation matrix
The Paint instance for method chaining
// Apply a combined transformation
const shape = new TVG.Shape();
shape.appendRect(0, 0, 100, 100);
// Create a matrix for: scale(2, 1.5) + rotate(45deg) + translate(100, 50)
const rad = (45 * Math.PI) / 180;
const cos = Math.cos(rad);
const sin = Math.sin(rad);
shape.transform({
e11: 2 * cos, e12: -2 * sin, e13: 100,
e21: 1.5 * sin, e22: 1.5 * cos, e23: 50,
e31: 0, e32: 0, e33: 1
});
Sets a clipping path for this paint object.
The clipping path restricts the area where the paint will be rendered. Only the parts of the paint that overlap with the clipper shape will be visible.
A Paint object (typically a Shape) to use as the clipping path
The Paint instance for method chaining
Sets a masking target object and the masking method.
The masking restricts the transparency of the source paint using the target paint.
A Paint object to use as the masking target
The method used to mask the source object with the target
The Paint instance for method chaining
Checks whether the given rectangular region intersects the filled area of the paint.
Useful for hit-testing, such as detecting whether a click or touch landed on a painted region. The paint must have been updated by a Canvas beforehand — typically after the canvas has been drawn and synchronized.
The x-coordinate of the region's top-left corner
The y-coordinate of the region's top-left corner
The width of the region. Must be greater than 0
The height of the region. Must be greater than 0
If true, hidden paints are excluded from the test (default: false)
true if any part of the region intersects the filled area, false otherwise
To test a single point, set width and height to 1. This test does not account for the results of blending or masking.
const shape = new TVG.Shape();
shape.appendRect(100, 100, 200, 200);
canvas.add(shape).render();
// Check if shape intersects with a region
if (shape.intersects(150, 150, 100, 100)) {
console.log('Shape intersects with region');
}
// Hit-test a single point, ignoring hidden paints
if (shape.intersects(event.offsetX, event.offsetY, 1, 1, true)) {
console.log('Clicked a visible part of the shape');
}
Protected_Create a new instance of this paint type with the given pointer Must be implemented by subclasses
Remove paint(s) from the scene If no paint is provided, removes all paints
Optionalpaint: PaintClear all paints from the scene (alias for remove())
Apply a Gaussian blur effect to the scene.
Blur intensity (> 0)
Blur direction: 0 (both), 1 (horizontal), 2 (vertical)
Reserved for border handling. Currently ignored.
Blur quality (0-100)
The Scene instance for method chaining
Beta
Apply a centered linear motion blur effect to the scene.
The blur is spread evenly on both sides of the content along the given angle. The scene transform applies to the blur vector.
Total blur length in scene-local units (>= 0)
Blur angle in degrees, measured clockwise from the positive x-axis. Default: 0
Blur quality (0-100)
The Scene instance for method chaining
Apply a drop shadow effect with Gaussian blur filter to the scene.
Red component (0-255)
Green component (0-255)
Blue component (0-255)
Alpha/opacity (0-255)
Shadow angle in degrees (0-360)
Shadow distance/offset
Blur intensity for the shadow (> 0)
Blur quality (0-100)
The Scene instance for method chaining
Override the scene content color with a given fill color.
Red component (0-255)
Green component (0-255)
Blue component (0-255)
Alpha/opacity (0-255)
The Scene instance for method chaining
Apply a tint effect to the scene using black and white color parameters.
Black tint red component (0-255)
Black tint green component (0-255)
Black tint blue component (0-255)
White tint red component (0-255)
White tint green component (0-255)
White tint blue component (0-255)
Tint intensity (0-100)
The Scene instance for method chaining
Apply a tritone color effect to the scene using three color parameters for shadows, midtones, and highlights. A blending factor determines the mix between the original color and the tritone colors.
Shadow red component (0-255)
Shadow green component (0-255)
Shadow blue component (0-255)
Midtone red component (0-255)
Midtone green component (0-255)
Midtone blue component (0-255)
Highlight red component (0-255)
Highlight green component (0-255)
Highlight blue component (0-255)
Blend factor (0-255)
The Scene instance for method chaining
Manually dispose of this object and free its WASM memory
Scene class for hierarchical grouping of Paint objects
Example
Example