crawl: Multi-color crawling text

Description Usage Arguments Details Value Examples

View source: R/crawl.R

Description

This function crawls over txt producing an animated gif-like representation of the text unfolding from left to right or top to bottom, depending on direction, colored according to colors.

Usage

1
2
3
4
5
6
7
8
crawl(
  txt = "hello world!",
  colors = NULL,
  recycle_chars = FALSE,
  direction = "vertical",
  pause = 0.05,
  ...
)

Arguments

txt

(character) Some text to color, stripped of line breaks

colors

(character) A vector of colors to color each individual character, if recycle_chars is TRUE, or the whole string if FALSE, defaulting to the Viridis Plasma palette. Must all be crayon-supported colors. Any colors in colors() or hex values (see ?rgb) are fair game.

recycle_chars

(logical) Should the vector of colors supplied apply to the entire string or should it apply to each individual character (if direction is vertical) or line (if direction is horizontal), and be recycled?

direction

(character) How should the colors be spread? One of "horizontal" or "vertical".

pause

(numeric) Seconds to pause between characters in seconds.

...

Further args passed to multi_color.

Details

This function requires as many colors as there are characters in your string and prints them one at a time. colors will be recycled in single-color equal-sized chunks if recycle_char is FALSE and character-by-character if recycle_char is TRUE.

Colors cannot be applied in RGUI (R.app on some systems) or other environments that do not support colored text. In these cases, the txt will simply be crawled over without applying colors.

Value

A string, printed in colors with pause seconds between printing each character.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
crawl()

crawl("It was a dark and stormy night")

crawl("Taste the rainbow", colors = "rainbow")

crawl(things[["hypnotoad"]],
  colors = c("purple", "blue", "cyan"),
  direction = "horizontal", recycle_chars = TRUE, pause = 0.01
)

options("keep.source = FALSE")
crawl("\014A long time ago in a galaxy far, far away...
It is a period of civil war. Rebel spaceships, striking from a hidden base,
have won their first victory against the evil Galactic Empire.")

## End(Not run)

multicolor documentation built on Nov. 4, 2021, 5:06 p.m.