Skip to contents

fill_charcoal() is a fill_noise() preset – same field, same rendering, just different defaults – tuned to read as hand-drawn charcoal or marker grain rather than fill_noise()'s more general-purpose rasterized field: a lighter base tone, finer/denser tiling, and finer noise detail.

Usage

fill_charcoal(
  color = "gray15",
  spacing = 0.25,
  aspect = NULL,
  resolution = 32L,
  alpha = 1,
  frequency = 4,
  octaves = 3L,
  seed = 1L,
  extend = "repeat"
)

Arguments

color

One or more fill colours, as in fill_noise(). Default "gray15" (lighter than fill_noise()'s own "black" default, closer to a charcoal tone).

spacing

Baseline tile size, as a fraction of the target's bounding box. Must be a positive number. Default 0.25 (finer than fill_noise()'s own 0.5 default, for denser grain).

aspect

Width-to-height ratio of the target polygon's bounding box. Must be a positive number, or NULL (the default) to resolve it automatically from the real target's own bounding-box aspect ratio at draw() time – see the fill class. Passing a fixed number instead computes the pattern once, immediately, against that value only.

resolution

Raster resolution (pixels per tile edge). Must be a positive integer of at least 2L. Default 32L.

alpha

Opacity. For a single color, the maximum opacity at the noise field's peak; for two or more, a flat opacity applied uniformly. Must be a number in (0, 1]. Default 1.

frequency

Noise frequency, as in shape_blob(). Must be non-negative. Default 4 (finer detail than fill_noise()'s own default of 1).

octaves

Number of noise octaves, as in shape_blob(). Must be a positive integer. Default 3L (one more layer of detail than fill_noise()'s own default of 2L).

seed

Integer seed for the noise field, as in shape_blob(). Default 1L.

extend

Passed to grid::pattern(). Default "repeat".

Value

A pattern object as returned by grid::pattern(), suitable for use as the fill argument to grid::gpar().

Details

Found, while prototyping shape_stroke()'s interior texture, to be a substantially better fit than fill_scribble() for a curved stroke's body – fill_scribble()'s angle is a single fixed value for the whole tile (and only tiles exactly seamlessly at a multiple of 90 degrees; see its "Known limitation" docs section), so it can't track a curved path's own continuously-varying tangent, producing hatching that visibly cuts across the stroke at odd angles wherever the path bends, while fill_noise()'s directionless mottling has no orientation to clash with the curve.

Examples

draw(shape_stroke(
  x = c(0, 1, 2, 3), y = c(0, 1, 0, 1), width = 0.4,
  fill = fill_charcoal(), color = NA_character_
))


# a lighter tone and a curved backbone -- fill_charcoal()'s directionless
# mottling tracks a bend that fill_scribble()'s fixed direction wouldn't
t <- seq(0, 2 * pi, length.out = 200)
draw(shape_stroke(
  x = t, y = sin(t), width = 0.3,
  fill = fill_charcoal(color = "gray40"), color = NA_character_
))