Created
December 26, 2023 05:17
-
-
Save HughParsonage/fd620a31489123ad85a7b0b48286069f to your computer and use it in GitHub Desktop.
Snow?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snow <- function() { | |
w <- getOption("width") | |
flakes <- c(rep(" ", 10), "*", " ", " ", "*", "❄︎", "❅", "❆") | |
falls <- | |
vapply(1:50, function(x) { | |
paste0(sample(flakes, size = w - 10, replace = TRUE), collapse = "") | |
}, FUN.VALUE = "") | |
panes <- lapply(1:50, function(x) { | |
paste0(c(rev(falls[seq_len(x)]), rep(strrep(" ", w), 50 - x)), | |
sep = "\n", collapse = "") | |
}) | |
repeat({ | |
for (i in seq_along(panes)) { | |
Sys.sleep(1) | |
cat(panes[[i]]) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment