interface RVG · Visuals
RvgVisual
interface RvgVisual
Something drawn in a group: a shape visual, a text, a point, a viewport or a group itself.
Every visual has three reactive properties that control how it is drawn: visible hides it,
mounted takes it out of the DOM, and zIndex sets the order among the visuals of its group.
Its coordinates are those of its group: toGraphic and fromGraphic convert between them and
the coordinates of the graphic.
Properties
mountedreadonly
mounted: BoolWhether the element is in the DOM.
An unmounted visual is removed from the DOM but keeps its reactive links: it is updated while
unmounted and comes back in its current state and at its z-order place. A hidden visual
(visible) stays in the DOM.
visiblereadonly
visible: BoolWhether the visual is drawn.
A hidden visual stays in the DOM, with display: none; it keeps its z-order place. For a
group, hiding it hides its content; the visuals in it keep their own visible.
zIndexreadonly
zIndex: IntegerThe drawing order among the visuals of the same group: a higher value is drawn on top.
Visuals with the same value are drawn in the order they were created. The default is 0. To
put a visual above the visuals of another group, change the zIndex of its group.
Methods
applyStyleDirective
applyStyleDirective(directive: string): voidChanges the CSS classes or the inline style.
The directive has the same form as the style string of the factories: words are class
names, to which the group's class prefix is added (a name starting with . gets no prefix);
@class-remove name removes a class; @style css sets the inline style and replaces the
previous inline style. Classes are added to the ones the visual has.
directive- The directive, for example
"selected"or"@style fill: #c33".
fromGraphic
fromGraphic(p: Point | VectorLike): PointConverts a position from the coordinates of the graphic into the coordinates of this visual's group, taking all anchors (moves, turns, scales) above it into account.
p- The position in the coordinates of the graphic.
Returns A new plain point.
getVisualBoundingBox
getVisualBoundingBox(): BoxThe smallest box around what is drawn, in the coordinates the visual's points are given in.
For a group, the box is in its own coordinates, inside its anchor. A hidden or unmounted visual gives an empty box at (0, 0). For a masked group, the box is clipped to the area of the mask's shapes; parts hidden within that area (e.g. by black mask shapes) are still included.
toGraphic
toGraphic(p: Point | VectorLike): PointConverts a position from the coordinates of this visual's group into the coordinates of the graphic.
p- The position in the coordinates of this visual's group.
Returns A new plain point.
