This function implements the rainbow smoke algorithm.

canvas_smoke(
  colors,
  init = 1,
  shape = c("bursts", "clouds"),
  algorithm = c("minimum", "average"),
  resolution = 150
)

Arguments

colors

a string or character vector specifying the color(s) used for the artwork.

init

an integer larger than zero and lower than or equal to resolution^2 specifying the initial number of pixels to color on the canvas.

shape

a character indicating the shape of the smoke. Possible options are burst and clouds.

algorithm

a character specifying how to select a new pixel. The default option minimum selects the pixel with the smallest color difference in a single neighbor and is relatively fast. The option average selects the pixel with the smallest average color difference in all the neighbors and is relatively slow.

resolution

resolution of the artwork in pixels per row/column. Increasing the resolution increases the quality of the artwork but also increases the computation time exponentially.

Value

A ggplot object containing the artwork.

See also

colorPalette

Author

Koen Derks, koen-derks@hotmail.com

Examples

# \donttest{
set.seed(1)

# Simple example
canvas_smoke(colors = "all", resolution = 500)


# Advanced example
reds <- colorRampPalette(c("red", "black"))
blues <- colorRampPalette(c("goldenrod", "navyblue"))
palette <- c(reds(100), blues(100))
canvas_smoke(colors = palette, init = 3, shape = "clouds", resolution = 500)

# }