Skip to contents

shape_blob is a drawable similar to shape_circle, except that its radius varies smoothly around the circumference according to Perlin/simplex noise generated with ambient.

shape_blobs() is a vectorized version of shape_blob(): each argument may be a vector, recycled against the others via purrr::pmap()'s own vctrs-based rules. The result is a sketch containing one shape_blob() per recycled row, rather than a single drawable.

Usage

shape_blob(
  x = 0,
  y = 0,
  radius = 1,
  range = 0.2,
  n = 100L,
  distortion = noise_field(),
  trans = trans_identity(),
  ...
)

shape_blobs(
  x = 0,
  y = 0,
  radius = 1,
  range = 0.2,
  n = 100L,
  distortion = noise_field(),
  trans = trans_identity(),
  ...
)

Arguments

x, y

Centroid coordinates. Default 0.

radius

Mean radius. Must be non-negative. Default 1.

range

Amplitude of the radius distortion. Must be non-negative. Default 0.2.

n

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

distortion

A noise_field controlling the radius distortion. Default noise_field().

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_blobs(), a sketch.

Details

Any length-1 element is broadcast to the common length; mismatched lengths greater than 1 raise an error. A shared distortion noise_field is automatically recycled across every blob; pass a list() of several different noise_fields instead to vary it per blob.

Examples

draw(shape_blob(
  radius = 1,
  range = 0.3,
  distortion = noise_field(seed = 4821)
))


# a larger range or lower frequency distortion gives a more irregular
# outline; a higher frequency gives a bumpier, lumpier one
draw(shape_blob(
  radius = 1,
  range = 0.6,
  distortion = noise_field(seed = 4821)
))

draw(shape_blob(
  radius = 1, range = 0.3,
  distortion = noise_field(frequency = 5, seed = 4821)
))


draw(shape_blob(
  radius = 1,
  range = 0.3,
  fill = fill_charcoal(),
  color = NA_character_
))


draw(shape_blobs(x = 1:3, radius = c(0.5, 1, 1.5), range = 0.2))


# a shared distortion recycles across every blob; a list() of several
# different noise_field()s varies it per blob instead
draw(shape_blobs(
  x = 1:3, radius = 0.8, range = 0.3,
  distortion = list(
    noise_field(seed = 1),
    noise_field(seed = 2),
    noise_field(seed = 3)
  )
))