Flips points across a vertical and/or horizontal line through the pivot
(about_x, about_y): x = TRUE mirrors left-right (flips the
x-coordinate), y = TRUE mirrors top-bottom (flips the y-coordinate).
Setting both reflects through the pivot point itself (equivalent to a
half turn, i.e. trans_rotate(pi, about_x, about_y)).
Details
Reflection across an arbitrary-angle line isn't exposed as a separate
argument – it composes from existing pieces instead: rotate the desired
line onto an axis, reflect, then rotate back, e.g.
trans_rotate(-theta) + trans_reflect(y = TRUE) + trans_rotate(theta)
reflects across a line through the origin at angle theta.
See also
Other transform helpers:
trans(),
trans_affine(),
trans_chain(),
trans_fn(),
trans_identity(),
trans_rotate(),
trans_scale(),
trans_shear(),
trans_translate(),
trans_warp()
Examples
draw(shape_bezier(
x = c(0, 0.5, 1),
y = c(0, 1, 0.2),
trans = trans_reflect(x = TRUE)
))
# overlay the original (faded) with each reflected copy (solid)
original <- shape_rectangle(
x = 1,
width = 1,
height = 0.4,
fill_alpha = 0.3,
color_alpha = 0.3
)
draw(sketch() + original + (original + trans_reflect(x = TRUE)))
draw(sketch() + original + (original + trans_reflect(y = TRUE)))
# reflecting through both axes is equivalent to a half turn
draw(shape_bezier(
x = c(0, 0.5, 1), y = c(0, 1, 0.2),
trans = trans_reflect(x = TRUE, y = TRUE)
))