interface RVG · Core

RvgMask

interface RvgMask

The mask of a group: shapes that decide where the group's content is shown.

A mask defines one or more geometric regions that control the visibility of elements within the associated group. The color supplied for each mask primitive determines the visibility strength of that region. Fully opaque or bright colors typically result in fully visible areas, while darker or more transparent colors reduce visibility. Intermediate values give partial transparency. Mask primitives accumulate until clear is called.

Methods

box

box(color: string, p1: Point | VectorLike, p2: Point | VectorLike): Box

Adds a box region defined by two opposite corners to the mask.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).
p1
One corner of the box.
p2
The opposite corner.

Returns The box of the region; changing it reshapes the region.

box(color: string): Box

Adds a box region with both corners initialized at the origin to the mask; set its corners later.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).

Returns The box of the region; changing it reshapes the region.

circle

circle(color: string): Circle

Adds a circular region with 3 points initialized at the origin to the mask; set its points later.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).

Returns The circle of the region; changing it reshapes the region.

circle(color: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike): Circle

Adds a circular region passing through 3 specified points to the mask.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).
p1
The first point.
p2
The second point.
p3
The third point.

Returns The circle of the region; changing it reshapes the region.

circleAt

circleAt(color: string, center: Point | VectorLike, radius: Real | NumberLike): Circle

Adds a circular region with the specified center and radius to the mask.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).
center
The center of the circle.
radius
The radius of the circle.

Returns The circle of the region; changing it reshapes the region.

clear

clear(): void

Removes all regions of the mask. Without regions, the group is not masked.

polygon

polygon(color: string, vertices: Sequence<Vector> | VectorsLike): Polygon

Adds a polygonal region with the specified vertices to the mask.

The given points are stored, not copied; convertibles such as [x, y] become new points. As with any polygon created from vertices, the region is not linked to them: changes through the returned polygon (e.g. setAt) reshape it, but for the region to follow when one of the stored points moves, call Reactive.linkVertices on the returned polygon. Reactive points must be in the same group as the mask (the masked group; otherwise an exception is thrown). For points from another group, e.g. handles outside the masked group, create an empty region with polygon(color) and set its vertices in a Reactive.do on the points (Polygons.polygon(handles, region)).

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).
vertices
The vertices of the polygon.

Returns The polygon of the region; changing it reshapes the region.

polygon(color: string): Polygon

Adds a polygonal region without vertices to the mask; add or set its vertices later.

color
The mask color of the region: bright, opaque colors show the group's content, dark or transparent ones hide it (see the remarks of RvgMask).

Returns The polygon of the region; changing it reshapes the region.