View source: R/pattern-geometry-wave.R
| grid.pattern_wave | R Documentation |
grid.pattern_wave() draws a wave pattern onto the graphic device.
names_wave is a character vector of supported type values.
grid.pattern_wave(
x = c(0, 0, 1, 1),
y = c(1, 0, 0, 1),
id = 1L,
...,
colour = gp$col %||% "grey20",
fill = gp$fill %||% "grey80",
angle = 30,
density = 0.2,
spacing = 0.05,
xoffset = 0,
yoffset = 0,
units = "snpc",
amplitude = 0.5 * spacing,
frequency = 1/spacing,
alpha = gp$alpha %||% NA_real_,
linetype = gp$lty %||% 1,
linewidth = size %||% gp$lwd %||% 1,
size = NULL,
grid = "square",
type = "indented",
reverse = FALSE,
stagger = FALSE,
default.units = "npc",
name = NULL,
gp = gpar(),
draw = TRUE,
vp = NULL
)
names_wave
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. |
colour |
Stroke colour(s). |
fill |
Fill colour(s) or |
angle |
Rotation angle in degrees. |
density |
Approx. fraction of area the pattern fills. |
spacing |
Spacing between repetitions of pattern (in |
xoffset |
Shift pattern along x axis (in |
yoffset |
Shift pattern along y axis (in |
units |
|
amplitude |
Wave amplitude (in |
frequency |
Linear frequency (in inverse |
alpha |
Alpha (between 0 and 1) or |
linetype |
Stroke linetype. |
linewidth |
Stroke linewidth. |
size |
For backwards compatibility can be used to set |
grid |
Adjusts placement and density of certain graphical elements.
|
type |
One of the following (see
|
reverse |
If |
stagger |
If |
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). |
A grid grob object invisibly. If draw is TRUE then also draws to the graphic device as a side effect.
Use grid.pattern_stripe() for straight filled bands or grid.pattern_line() for stroked lines instead of waves.
See https://en.wikipedia.org/wiki/Line_(heraldry) and https://en.wikipedia.org/wiki/Waveform for more information about the supported wave types.
print(names_wave)
# visual table of all wave types
grid::grid.newpage()
n <- length(names_wave)
nc <- 2L
nr <- ceiling(n / nc)
grid::pushViewport(grid::viewport(layout = grid::grid.layout(nr, nc)))
for (i in seq_len(n)) {
grid::pushViewport(grid::viewport(
layout.pos.row = (i - 1L) %/% nc + 1L,
layout.pos.col = (i - 1L) %% nc + 1L
))
grid.pattern_wave(colour = "black", fill = c("gold", "steelblue"),
type = names_wave[i], density = 0.18, spacing = 0.45,
angle = 0, amplitude = 0.100, frequency = 1 / 0.45)
grid::grid.rect(x = 0.5, y = 0.86, width = 0.5, height = 0.28,
just = "centre", gp = grid::gpar(fill = "grey80", col = "black"))
grid::grid.text(names_wave[i], x = 0.5, y = 0.88,
gp = grid::gpar(fontsize = 11))
grid::grid.rect(gp = grid::gpar(fill = "transparent", col = "black", lwd = 6))
grid::popViewport()
}
grid::popViewport()
# stagger shifts alternate rows by half a wavelength
grid::grid.newpage()
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_wave(x_hex, y_hex, colour = "black", type = "urdy",
fill = c("red", "blue"), density = 0.3,
spacing = 0.15, angle = 0,
amplitude = 0.045, frequency = 1 / 0.15, stagger = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.