grid.pattern_ambient {gridpattern} | R Documentation |
Ambient patterned grobs
Description
grid.pattern_ambient()
draws noise patterns onto the graphic device powered by the ambient
package.
Usage
grid.pattern_ambient(
x = c(0, 0, 1, 1),
y = c(1, 0, 0, 1),
id = 1L,
...,
type = "simplex",
fill = gp$fill %||% "grey80",
fill2 = "#4169E1",
frequency = 0.01,
interpolator = "quintic",
fractal = switch(type, worley = "none", "fbm"),
octaves = 3,
lacunarity = 2,
gain = 0.5,
pertubation = "none",
pertubation_amplitude = 1,
value = "cell",
distance_ind = c(1, 2),
jitter = 0.45,
res = getOption("ggpattern_res", 72),
alpha = NA_real_,
default.units = "npc",
name = NULL,
gp = gpar(),
draw = TRUE,
vp = NULL
)
Arguments
x |
A numeric vector or unit object specifying x-locations of the pattern boundary. |
y |
A numeric vector or unit object specifying y-locations of the pattern boundary. |
id |
A numeric vector used to separate locations in x, y into multiple boundaries.
All locations within the same |
... |
Currently ignored. |
type |
Either cubic, perlin, simplex, value, white, or worley |
fill |
Colour. |
fill2 |
Second colour. |
frequency |
Determines the granularity of the features in the noise. |
interpolator |
How should values between sampled points be calculated?
Either |
fractal |
The fractal type to use. Either |
octaves |
The number of noise layers used to create the fractal noise.
Ignored if |
lacunarity |
The frequency multiplier between successive noise layers
when building fractal noise. Ignored if |
gain |
The relative strength between successive noise layers when
building fractal noise. Ignored if |
pertubation |
The pertubation to use. Either |
pertubation_amplitude |
The maximal pertubation distance from the
origin. Ignored if |
value |
The noise value to return. Either
|
distance_ind |
Reference to the nth and mth closest points that should
be used when calculating |
jitter |
The maximum distance a point can move from its start position during sampling of cell points. |
res |
Assumed resolution (in pixels per graphic device inch) to use when creating array pattern. |
alpha |
Alpha (between 0 and 1) or |
default.units |
A string indicating the default units to use if |
name |
A character identifier. |
gp |
An object of class |
draw |
A logical value indicating whether graphics output should be produced. |
vp |
A Grid viewport object (or NULL). |
Value
A grid grob object invisibly. If draw
is TRUE
then also draws to the graphic device as a side effect.
See Also
For more information about the noise types please see the relevant ambient
documentation:
ambient::noise_cubic()
, ambient::noise_perlin()
, ambient::noise_simplex()
,
ambient::noise_value()
, ambient::noise_white()
, and ambient::noise_worley()
.
grid.pattern_plasma()
provides an alternative noise pattern that depends on magick
.
Examples
if (requireNamespace("ambient", quietly = TRUE)) {
x_hex <- 0.5 + 0.5 * cos(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
y_hex <- 0.5 + 0.5 * sin(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
grid.pattern_ambient(x_hex, y_hex, fill = "green", fill2 = "blue")
}
if (requireNamespace("ambient")) {
grid::grid.newpage()
grid.pattern_ambient(x_hex, y_hex, fill = "green", fill2 = "blue", type = "cubic")
}