Scales points by sx/sy along the x/y axes, about the pivot
(about_x, about_y).
See also
Other transform helpers:
trans(),
trans_affine(),
trans_chain(),
trans_fn(),
trans_identity(),
trans_reflect(),
trans_rotate(),
trans_shear(),
trans_translate(),
trans_warp()
Examples
draw(shape_square(side = 1, trans = trans_scale(2)))
draw(shape_square(side = 1, trans = trans_scale(2, 0.5)))
# overlay the original (faded) with the scaled copy (solid)
original <- shape_rectangle(
width = 1.5,
height = 0.6,
fill_alpha = 0.3,
color_alpha = 0.3
)
draw(sketch() + original + (original + trans_scale(1.5, 0.7)))
# scaling about a pivot other than the shape's own centroid also moves
# it, since distance from the pivot is what gets scaled -- shown here
# against a fixed frame, with a small marker at the pivot
square <- shape_square(
x = 1,
side = 0.5,
fill_alpha = 0.3,
color_alpha = 0.3
)
pivot <- shape_circle(radius = 0.05, fill = "tomato", color = NA_character_)
draw(
sketch() + square +
(square + trans_scale(2, about_x = 0, about_y = 0)) +
pivot,
xlim = c(-3, 3), ylim = c(-3, 3)
)