roundedRect

A rectangle with rounded corners.

roundedRect(x: Val, y: Val, width: Val, height: Val, rounding: Val): Expr

Import shape from shaders/std and use shape.roundedRect.

width and height are half-extents (the distance from the centre to each side), in uv. rounding is the corner radius. Pass 0 for a sharp rectangle.

Parameters

NameTypeNotes
xVal
yVal
widthVal
heightVal
roundingVal

Example

shape: {distance: ({x, y}, u) => roundedRect(x, y, u('width'), u('height'), u('rounding')), …}

Tip. A width of 0.5 spans the full canvas height, not half of it.

See also

  • parallelogram — A parallelogram: a rectangle with its top edge slid sideways.
  • trapezoid — A trapezoid: a four-sided shape with a flat top and bottom of different widths.
  • cross — A plus-shaped cross with four equal arms.

Used by

RoundedRect, Waveform