Skip to contents

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.

Value

list of stimuli with rotated tems and/or images

See also

Stimulus manipulation functions align(), crop_tem(), crop(), greyscale(), horiz_eyes(), image_func(), mask_oval(), mask(), mirror(), pad(), resize(), to_size()

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)
# }