Skip to contents

shape_circle is a drawable defined by a centroid and a radius; its vertices are computed as evenly spaced points around the circumference.

shape_circles() is a vectorized version of shape_circle(): each argument may be a vector, recycled against the others. The result is a sketch containing one shape_circle() per recycled row, rather than a single drawable.

Usage

shape_circle(x = 0, y = 0, radius = 1, n = 100L, trans = trans_identity(), ...)

shape_circles(
  x = 0,
  y = 0,
  radius = 1,
  n = 100L,
  trans = trans_identity(),
  ...
)

Arguments

x, y

Centroid coordinates. Default 0.

radius

Radius. Must be non-negative. Default 1.

n

Number of points used to approximate the circle. Default 100L.

trans

A trans object applied to the shape's computed points. Default trans_identity() (no transform).

...

Arguments passed to style().

Value

A drawable.

For shape_circles(), a sketch.

Details

Recycling uses purrr::pmap()'s own vctrs-based rules: any length-1 element is broadcast to the common length; mismatched lengths greater than 1 raise an error.

Examples

draw(shape_circle(radius = 1))

draw(shape_circle(x = 1, y = 1, radius = 0.5, n = 6, color = "darkred"))

draw(shape_circle(radius = 1, fill = "steelblue", color = NA_character_))

draw(shape_circle(radius = 1, fill = fill_hatch(angle = 30)))


draw(shape_circles(x = 1:3, radius = c(0.5, 1, 1.5)))


# each argument recycles independently, so colour can vary alongside position
draw(shape_circles(
  x = cos(seq(0, 2 * pi, length.out = 9))[-9],
  y = sin(seq(0, 2 * pi, length.out = 9))[-9],
  radius = 0.3,
  fill = rep(c("tomato", "steelblue"), length.out = 8)
))