This function draws the Physarum polycephalum slime mold on a canvas. The algorithm simulates particles on a two-dimensional grid that move towards areas on the grid with a high intensity.
canvas_slime(
colors,
background = "#000000",
iterations = 2000,
agents = 1000,
layout = c(
"random", "gaussian", "circle", "grid",
"clusters", "arrows", "wave", "spiral"
),
resolution = 1000
)
a character (vector) specifying the color(s) used for the artwork.
a character specifying the color used for the background.
a positive integer specifying the number of iterations of the algorithm.
a positive integer specifying the number of agents to use.
a character specifying the initial layout of the agents.
Possible options are random
(default), gaussian
,
circle
, grid
, clusters
, arrows
and wave
.
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.
A ggplot
object containing the artwork.
colorPalette
# \donttest{
set.seed(1)
# Simple example
canvas_slime(colors = colorPalette("neon1"))
# }