tests/testthat/test-animate.R

test_that("animate", {
  stimuli <- demo_stim()
  x <- animate(stimuli)
  expect_equal(length(x), 1)
  
  img <- x[[1]]$img
  expect_equal(length(img), 2)
  
  info <- magick::image_info(img)
  expect_equal(info$format, rep("gif", 2))
  
  ## args
  x <- demo_stim(1) |> rep(4) |>
    rotate(c(0, 90, 180, 270)) |>
    animate(fps = 4, loop = 2, rev = TRUE)
  
  # rev = TRUE doubles the frames
  img <- x[[1]]$img
  expect_equal(length(img), 8)
  
  # with the second centre having matte == FALSE
  info <- magick::image_info(img)
  expect_equal(info$format, rep("gif", 8))
  expect_equal(info$matte, c(F, F, F, F, T, F, F, F))
})

Try the webmorphR package in your browser

Any scripts or data that you put into this service are public.

webmorphR documentation built on June 2, 2022, 5:07 p.m.