Rotate templates and images
Usage
rotate(
stimuli,
degrees = 0,
fill = wm_opts("fill"),
keep_size = TRUE,
origin = "image"
)
Arguments
- stimuli
list of stimuli
- degrees
degrees to rotate
- fill
background color, see
color_conv()
- keep_size
whether to keep the original size or expand images to the new rotated size
- origin
The origin of the rotation. Options are:
"image"
will rotate around the image center."tem"
will rotate around the average of all template coordinates.A vector of 1 or more point indices (0-based) will rotate around their average position.
Examples
stimuli <- demo_stim() |> resize(0.5)
rotate(stimuli, 45, fill = "dodgerblue")
rotate(stimuli, 45, fill = "dodgerblue", keep_size = FALSE)
# \donttest{
# if images are not in the centre of the image,
# try setting the origin to tem or specific point(s)
offset <- stimuli[1] |>
draw_tem() |>
pad(0, 250, 0, 0, fill = "dodgerblue")
rotate(offset, 45, origin = "image", fill = "pink")
rotate(offset, 45, origin = "tem", fill = "pink")
# rotate around point 0 (left eye)
offset |> crop_tem() |> rep(8) |>
rotate(seq(0, 325, 45), origin = 0, fill = "pink") |>
animate(fps = 5)
# }