canvas_slime: Draw A Slime Mold

View source: R/canvas_slime.R

canvas_slimeR Documentation

Draw A Slime Mold

Description

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.

Usage

canvas_slime(
  colors,
  background = "#000000",
  iterations = 2000,
  agents = 1000,
  layout = c(
     "random", "gaussian", "circle", "grid",
     "clusters", "arrows", "wave", "spiral"
  ),
  resolution = 1000
)

Arguments

colors

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

background

a character specifying the color used for the background.

iterations

a positive integer specifying the number of iterations of the algorithm.

agents

a positive integer specifying the number of agents to use.

layout

a character specifying the initial layout of the agents. Possible options are random (default), gaussian, circle, grid, clusters, arrows and wave.

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.

Author(s)

Koen Derks, koen-derks@hotmail.com

References

https://cargocollective.com/sagejenson/physarum

https://fronkonstin.com/2020/08/11/abstractions/

See Also

colorPalette

Examples


set.seed(1)

# Simple example
canvas_slime(colors = colorPalette("neon1"))



aRtsy documentation built on June 8, 2025, 10:48 a.m.