shape_twist is like shape_ribbon, but the underlying path is a
Brownian bridge rather than a straight line, giving the polygon a
wandering, twisted appearance.
shape_twists() is a vectorized version of shape_twist(): 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_twist() per recycled row, rather than a single
drawable.
Usage
shape_twist(
x = 0,
y = 0,
xend = 1,
yend = 1,
width = 0.2,
n = 100L,
path_distortion = noise_bridge(),
distortion = noise_field(),
trans = trans_identity(),
...
)
shape_twists(
x = 0,
y = 0,
xend = 1,
yend = 1,
width = 0.2,
n = 100L,
path_distortion = noise_bridge(),
distortion = noise_field(),
trans = trans_identity(),
...
)Arguments
- x, y
Start point. Default
0.- xend, yend
End point. Default
1.- width
Maximum width. Must be non-negative. Default
0.2.- n
Number of points used along the path. Default
100L.- path_distortion
A noise_bridge controlling the path's Brownian bridge. Default
noise_bridge().- distortion
A noise_field controlling the width modulation. Default
noise_field().- trans
A trans object applied to the shape's computed points. Default
trans_identity()(no transform).- ...
Arguments passed to
style().
Details
Any length-1 element is broadcast to the common length; mismatched
lengths greater than 1 raise an error. A shared
path_distortion/distortion is automatically recycled across every
twist; pass a list() of several different noise_bridge/noise_field
objects instead to vary either per twist – as in README.Rmd's
"Twists" example, which gives every twist the same path_distortion
this way.
Examples
draw(shape_twist(
x = 0, y = 0, xend = 1, yend = 0, width = 0.2,
path_distortion = noise_bridge(seed = 7734)
))
# more smoothing passes make the Brownian bridge wander more gently;
# fewer passes leave it jumpier
draw(shape_twist(
x = 0, y = 0, xend = 1, yend = 0, width = 0.2,
path_distortion = noise_bridge(smooth = 20L, seed = 7734)
))
draw(shape_twist(
x = 0, y = 0, xend = 1, yend = 0, width = 0.2,
path_distortion = noise_bridge(smooth = 0L, seed = 7734)
))
draw(shape_twists(x = 1:3, y = 0, xend = 2:4, yend = 1, width = 0.2))
# every twist sharing one path_distortion gives them a family
# resemblance, as in README.Rmd's "Twists" example
draw(shape_twists(
x = 0, y = 1:5, xend = 3, yend = 1:5, width = 0.15,
path_distortion = noise_bridge(seed = 2020)
))