R/social_distance_02.R

Defines functions social_distance_02

Documented in social_distance_02

# https://www.flickr.com/photos/stringrbelle/49656406813/

#' @rdname rosemary
#' @export
social_distance_02 <- function(dir = NULL, ...) {

  dir <- check_dir(dir)
  file <- file.path(dir, "social_distance_02.png")

  dat <- jasmines::use_seed(255) %>%
    jasmines::scene_mix(
      n = 500, xpos = 1:80, ypos = 1:80,
      grain = 2, size = 1, entity = "circle"
    ) %>%
    jasmines::unfold_tempest(iterations = 50) %>%
    dplyr::mutate(x = x/10, y = y/10) %>%
    jasmines::unfold_warp(iterations = 30) %>%
    dplyr::mutate(sigh = id + ind) %>%
    dplyr::filter(time > 10) %>%
    dplyr::mutate(time = time - 10)


  pal <- jasmines::palette_adjust(
    name = "rainbow",
    prefix = NULL,
    red.f = .5,
    blue.f = .8,
    green.f = .8
  )

  dat %>%
    jasmines::style_ribbon(
      colour = "sigh",
      palette = pal,
      background = "wheat",
      alpha = c(.1, .1)
    ) %>%
    jasmines::export_image(
      filename = file
    )

  cat("image written to:", file, "\n")
  return(invisible(NULL))

}
djnavarro/rosemary documentation built on March 16, 2020, 9:54 p.m.