R/blank.R

Defines functions blank

Documented in blank

#' Make blank images
#'
#' @param n the number of images to return
#' @param width width of the images
#' @param height height of the images
#' @param color background colour of the images
#' @param names names of the images
#'
#' @return stimlist with labelled images
#' @export
#'
#' @examples
#' blank(5, 100, 300, color = rainbow(5)) %>%
#'   plot()
blank <- function(n = 1, width = 100, height = 100, color = "white", names = "img") {
  color <- rep_len(color, n)
  if (length(names) < n) names <- rep_len(names, n)
  names(color) <- paste0(names, 1:n)
  stimuli <- lapply(color, function(color) {
    stim <- list(
      img = magick::image_blank(width, height, color),
      desc = "Blank",
      width = width,
      height = height
    )
    class(stim) <- "stim"
    stim
  })

  class(stimuli) <- "stimlist"

  stimuli
}
facelab/webmorph documentation built on April 11, 2021, 6:34 a.m.