interface RVG · Factories
RvgVisualFactory
interface RvgVisualFactory
Creates the drawn shapes of a group: points, polygons, polylines, segments, boxes, circles, arcs, rectangles and triangles.
Reach it through visuals of a group. Each function takes a style first, the same string as for
applyStyleDirective: class names (with the group's class prefix) and @style … for inline CSS.
A visual is also a shape: it holds the points it gets, as described on Shape, so computations
accept it, and a visual made from a shape of shapes shares that shape's points. Without points,
they are at (0, 0).
Numbers given as a Real (the radius of circleAt) are read once, when the visual is created;
to keep the visual up to date, write it with a computation in Reactive.do, for example
Circles.circleAt(center, radius, circle).
Properties
defaultZIndex
defaultZIndex: numberThe z-index given to visuals created from now on (default 0).
Within one group, a visual with a higher z-index is drawn on top and gets the pointer first;
with equal z-index, the one created later is on top. The default is applied at creation, so
set it before creating the visuals; change a single visual with its zIndex. The z-index
orders only siblings in the same group: a layer is ordered as a whole inside its parent.
Methods
arc
arc(style: string): RvgArcCreates a circular arc with 3 points initialized at the origin.
style- The visual style to apply to the arc.
Returns An arc visual instance.
arc(style: string, start: Point | VectorLike, middle: Point | VectorLike, end: Point | VectorLike): RvgArcCreates a circular arc passing through exactly 3 specified points.
style- The visual style to apply to the arc.
start- The start point of the arc.
middle- The middle point on the arc.
end- The end point of the arc.
Returns An arc visual instance.
box
box(style: string): RvgBoxCreates a box initialized at the origin.
style- The visual style to apply to the box.
Returns A box visual instance.
box(style: string, p1: Point | VectorLike, p2: Point | VectorLike): RvgBoxCreates a box spanned by two points.
style- The visual style to apply to the box.
p1- The first corner.
p2- The opposite corner.
Returns A box visual instance.
circle
circle(style: string): RvgCircleCreates a circle with 3 points initialized at the origin.
style- The visual style to apply to the circle.
Returns A circle visual instance.
circle(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike): RvgCircleCreates a circle passing through exactly 3 specified points.
style- The visual style to apply to the circle.
p1- The first point.
p2- The second point.
p3- The third point.
Returns A circle visual instance.
circleAt
circleAt(style: string, center: Point | VectorLike, radius: Real | NumberLike): RvgCircleCreates a circle at a specified center with a specified radius.
style- The visual style to apply to the circle.
center- The center of the circle.
radius- The radius of the circle.
Returns A circle visual instance.
point
point(style: string, p: Point | VectorLike): RvgPointCreates a visual marker at the specified point location.
style- The visual style to apply to the point.
p- The point where the visual element should be positioned.
Returns A point visual instance.
point(style: string): RvgPointCreates a visual marker at the origin (0,0).
style- The visual style to apply to the point.
Returns A point visual instance.
polygon
polygon(style: string, vertices: Sequence<Vector> | VectorsLike): RvgPolygonCreates a polygon from a collection of vertices.
style- The visual style to apply to the polygon.
vertices- The points defining the polygon.
Returns A polygon visual instance.
polygon(style: string): RvgPolygonCreates an empty polygon.
style- The visual style to apply to the polygon.
Returns A polygon visual instance with no vertices.
polygon(style: string, size: number): RvgPolygonCreates a polygon with a specified number of vertices initialized at the origin.
style- The visual style to apply to the polygon.
size- The number of vertices.
Returns A polygon visual instance.
polygon3P
polygon3P(style: string): RvgPolygonCreates a polygon with 3 vertices initialized at the origin.
style- The visual style to apply to the polygon.
Returns A polygon visual instance.
polygon3P(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike): RvgPolygonCreates a polygon with exactly 3 specified points.
style- The visual style to apply to the polygon.
p1- The first vertex.
p2- The second vertex.
p3- The third vertex.
Returns A polygon visual instance.
polygon4P
polygon4P(style: string): RvgPolygonCreates a polygon with 4 vertices initialized at the origin.
style- The visual style to apply to the polygon.
Returns A polygon visual instance.
polygon4P(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, p4: Point | VectorLike): RvgPolygonCreates a polygon with exactly 4 specified points.
style- The visual style to apply to the polygon.
p1- The first vertex.
p2- The second vertex.
p3- The third vertex.
p4- The fourth vertex.
Returns A polygon visual instance.
polyline
polyline(style: string, vertices: Sequence<Vector> | VectorsLike): RvgPolylineCreates a polyline from a collection of vertices.
style- The visual style to apply to the polyline.
vertices- The points defining the polyline.
Returns A polyline visual instance.
polyline(style: string): RvgPolylineCreates an empty polyline.
style- The visual style to apply to the polyline.
Returns An empty polyline visual.
polyline(style: string, size: number): RvgPolylineCreates a polyline with a specified number of vertices initialized at the origin.
style- The visual style to apply to the polyline.
size- The number of vertices.
Returns A polyline visual instance.
polyline3P
polyline3P(style: string): RvgPolylineCreates a polyline with 3 vertices initialized at the origin.
style- The visual style to apply to the polyline.
Returns A polyline visual instance.
polyline3P(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike): RvgPolylineCreates a polyline with exactly 3 specified points.
style- The visual style to apply to the polyline.
p1- The first vertex.
p2- The second vertex.
p3- The third vertex.
Returns A polyline visual instance.
polyline4P
polyline4P(style: string): RvgPolylineCreates a polyline with 4 vertices initialized at the origin.
style- The visual style to apply to the polyline.
Returns A polyline visual instance.
polyline4P(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, p4: Point | VectorLike): RvgPolylineCreates a polyline with exactly 4 specified points.
style- The visual style to apply to the polyline.
p1- The first vertex.
p2- The second vertex.
p3- The third vertex.
p4- The fourth vertex.
Returns A polyline visual instance.
rectangle
rectangle(style: string): RvgRectangleCreates a rectangle initialized at the origin.
style- The visual style to apply to the rectangle.
Returns A rectangle visual instance.
segment
segment(style: string): RvgSegmentCreates a line segment initialized at the origin.
style- The visual style to apply to the line segment.
Returns A line segment visual instance.
segment(style: string, p1: Point | VectorLike, p2: Point | VectorLike): RvgSegmentCreates a line segment between two specified points.
style- The visual style to apply to the line segment.
p1- The start point.
p2- The end point.
Returns A line segment visual instance.
segment(style: string, segment: Segment | ShapeLike): RvgSegmentCreates a line segment visual that shares the points of an existing segment.
style- The visual style to apply to the line segment.
segment- The line segment geometry to visualize.
Returns A line segment visual instance.
triangle
triangle(style: string, p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike): RvgTriangleCreates a triangle with the specified vertices.
style- The visual style to apply to the triangle.
p1- The first vertex.
p2- The second vertex.
p3- The third vertex.
Returns A triangle visual instance.
triangle(style: string): RvgTriangleCreates a triangle with 3 vertices initialized at the origin.
style- The visual style to apply to the triangle.
Returns A triangle visual instance.
