Shape component that defines visual properties (fill, stroke, transforms) and geometry children (Rect, Circle, Path) that define what to draw.
The Shape Component
TheShape component is a container that holds visual properties and must contain geometry children to be rendered.
Shape Props
See the complete reference in the type definitions in the source code.Fill color as RGBA tuple
[R, G, B, A]. Each component is 0-255.Stroke color as RGBA tuple
[R, G, B, A].Width of the stroke in pixels.
Stroke dash pattern as an array of lengths.
Offset for stroke dash pattern in pixels.
Cap style for stroke endpoints (
'butt', 'round', 'square').Join style for stroke corners (
'miter', 'round', 'bevel').Miter limit for stroke joins.
Opacity value from 0 (transparent) to 255 (opaque).
Fill rule for determining shape interior (
'nonzero' or 'evenodd').Shapes also support transform props (
x, y, rotation, scaleX, scaleY). See Transforms for details.Geometry Children
Geometry children define the actual shape to be drawn. AShape can contain one or more geometry children.
Rect (Rectangle)
Defines a rectangle or rounded rectangle.Rect Props
X-coordinate of the rectangle’s top-left corner.
Y-coordinate of the rectangle’s top-left corner.
Width of the rectangle in pixels.
Height of the rectangle in pixels.
Horizontal corner radius for rounded rectangles.
Vertical corner radius for rounded rectangles.
Rounded Rectangle Example
Circle (Circle/Ellipse)
Defines a circle or ellipse.Circle Props
X-coordinate of the circle’s center.
Y-coordinate of the circle’s center.
Radius for a perfect circle. If specified, both radii will use this value.
Horizontal radius for an ellipse.
Vertical radius for an ellipse.
Ellipse Example
Path (Custom Shapes)
Defines custom shapes using path commands similar to SVG paths.Path Props
Array of path command types. Use
PathCommand constants:PathCommand.MoveTo- Move to a point (1 point)PathCommand.LineTo- Draw line to a point (1 point)PathCommand.CubicTo- Draw cubic bezier curve (3 points)PathCommand.Close- Close the path (0 points)
Array of points corresponding to the commands. Each point is
{ x: number, y: number }.Bezier Curve Example
Multiple Geometry Children
A singleShape can contain multiple geometry children, which will be rendered together with the same visual properties.