circle

A circle of a given radius.

circle(x: Val, y: Val, radius: Val): Expr

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

radius is in uv (1 = the canvas height). Returns the signed distance to the edge, negative inside.

Parameters

NameTypeNotes
xVal
yVal
radiusVal

Example

shape: {distance: ({x, y}, u) => circle(x, y, u('radius')), bounds: {size: {width: 'radius', height: 'radius'}}, …}

Tip. Blend a sharp shape toward this one with math.mix to round it off (the Polygon shader does).

See also

  • ellipse — An ellipse with separate horizontal and vertical radii.
  • ring — A ring: a circular band around a centre.
  • polygon — A regular polygon with any number of sides.

Used by

Circle, Polygon, Waveform