Skip to content

Shapes ​

The geometry components. Every shape inherits the full shared graphic props — color, style, opacity, blendMode, the stroke attributes, dash, transform, animate, and declarative shader/filter children — so the tables below list only the geometry each shape adds.

Rendered shapes — circles, rects, RRect, ellipse, line and points at varying opacity
tsx
import {
  Circle,
  Ellipse,
  Line,
  Rect,
  RRect,
  Polyline,
  Polygon,
  Points,
  Path,
} from "@scumble/react";

<Circle> ​

A circle defined by its center and radius.

tsx
<Circle cx={50} cy={50} radius={30} color="#3b82f6" />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
cxnumber0Center x (dp).
cynumber0Center y (dp).
radiusnumber—Radius (dp). Required.

<Ellipse> ​

Axis-aligned ellipse defined by its center and two radii. A circle is the rx === ry special case (see <Circle>).

tsx
<Ellipse cx={100} cy={50} rx={80} ry={40} color="#3b82f6" />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
cxnumber0Center x (dp).
cynumber0Center y (dp).
rxnumber—Horizontal radius (dp). Required.
rynumber—Vertical radius (dp). Required.

<Line> ​

Straight line from (x1, y1) to (x2, y2). Always stroked — a line has no interior to fill — so style defaults to "stroke" (unlike the other shapes) and an explicit style="fill" is ignored natively.

tsx
<Line x1={0} y1={0} x2={100} y2={80} color="#3b82f6" strokeWidth={4} />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
x1number0Start point x (dp).
y1number0Start point y (dp).
x2number0End point x (dp).
y2number0End point y (dp).

<Rect> ​

Axis-aligned rectangle.

tsx
<Rect x={10} y={10} width={80} height={50} color="#ff0000" />
<Rect width={100} height={100} color="#000" style="stroke" strokeWidth={2} />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
xnumber0Left edge x (dp).
ynumber0Top edge y (dp).
widthnumber—Width (dp). Required.
heightnumber—Height (dp). Required.

<RRect> ​

Rounded rectangle — a <Rect> with corner radii.

tsx
<RRect x={10} y={10} width={80} height={80} radii={16} color="red" />
<RRect width={100} height={100} radii={{ x: 10, y: 20 }} color="blue" />
// Only the top corners rounded (bottom-sheet / card shapes):
<RRect width={120} height={80} radii={[{ x: 16, y: 16 }, { x: 16, y: 16 }, { x: 0, y: 0 }, { x: 0, y: 0 }]} color="green" />

Props ​

All RectProps (and the shared graphic props), plus:

PropTypeDefaultDescription
radiinumber | CornerRadius | CornerRadii—Corner radii: a number is uniform, {x, y} is uniform per-axis, and a 4-corner array is [top-left, top-right, bottom-right, bottom-left] (per corner {x, y}). Negative radii clamp to 0; radii too large for the rect are shrunk to fit at draw time.

<Polyline> ​

Open polyline through the given vertices. Stroked by default (an open polyline has no interior); pass style="fill" to fill it as if closed.

tsx
<Polyline points="10,10 60,80 110,20 160,90" color="#3b82f6" strokeWidth={4} />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
pointsstring | Vec[]—The vertices, as an SVG points string ("0,0 20,30 50,10") or {x, y} pairs (e.g. from vec). Required.

<Polygon> ​

Closed polygon through the given vertices — a closing segment from the last vertex back to the first is appended automatically. Filled by default, like the other closed shapes.

tsx
<Polygon points="50,0 100,90 0,90" color="#22c55e" />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
pointsstring | Vec[]—The vertices, as an SVG points string or {x, y} pairs — the shape is implicitly closed. Required.

<Points> ​

A point set with Skia drawPoints semantics: dots, line segments, or an open polyline through the vertices. Stroked by default in every mode.

tsx
<Points points="10,10 60,80 110,20 160,90" color="#3b82f6" strokeWidth={8} />
<Points points="10,10 60,80 110,20 160,90" mode="lines" color="#f00" strokeWidth={2} />

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
pointsstring | Vec[]—The vertices, as an SVG points string or {x, y} pairs. Required.
mode"points" | "lines" | "polygon""points""points" draws a dot per vertex — the dot's diameter is strokeWidth and strokeCap defaults to "round" (a butt cap would leave a zero-length segment invisible); "lines" draws a segment per vertex pair; "polygon" strokes an open polyline through all vertices.

<Path> ​

SVG path. path is an SVG d string (full command set M/L/H/V/C/S/Q/T/A/Z, relative and absolute, including concatenated arc flags) or a Path2D object built command-style — the two are interchangeable. A Path2D returned by Path2D.op() (lazy boolean composition) rides a separate channel; the native renderer evaluates the ops at draw time.

tsx
// from an SVG d string
<Path path="M10 10 L90 90 Z" color="#22c55e" />;

// from a Path2D (command-style)
const p = new Path2D().moveTo(10, 10).lineTo(90, 90).close();
<Path path={p} color="#22c55e" />;

// boolean composition, evaluated natively at render time
const mask = Path2D.op(circle, square, "difference");
<Path path={mask} color="#3b82f6" />;

start/end trim the path — animating them (as pathStart/pathEnd, see Animation) is the classic draw-on effect.

Props ​

All shared graphic props, plus:

PropTypeDefaultDescription
pathstring | Path2D—SVG path data string, or a Path2D object built command-style. Required.
fillRule"nonzero" | "even-odd"—Fill rule for the path. The parser also accepts the hyphenated "even-odd".
startnumber0Trim the start of the path — a normalized path-length fraction in [0, 1]. Applied to both fill and stroke; each contour of a multi-contour path is trimmed independently (Skia trim semantics).
endnumber1Trim the end of the path — a [0, 1] fraction. See start.

Released under the Apache License 2.0.