Title: | Generative Art with 'ggplot2' |
---|---|
Description: | Provides algorithms for creating artworks in the 'ggplot2' language that incorporate some form of randomness. |
Authors: | Koen Derks [aut, cre] |
Maintainer: | Koen Derks <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.1 |
Built: | 2025-02-22 01:20:32 UTC |
Source: | https://github.com/koenderks/artsy |
ggplot2
aRtsy
aims to make generative art accessible to the general public in a straightforward and standardized manner.
The package provides algorithms for creating artworks that incorporate some form of randomness and are dependent on the set seed
.
Each algorithm is implemented in a separate function with its own set of parameters that can be tweaked.
For documentation on aRtsy
itself, including the manual and user guide
for the package, worked examples, and other
tutorial information visit the package website.
Koen Derks (maintainer, author) | <[email protected]> |
Please use the citation provided by R when citing this package.
A BibTex entry is available from citation("aRtsy")
.
Useful links:
The twitter feed to check the artwork of the day.
The issue page to submit a bug report or feature request.
This function draws Langton's Ant on a canvas. Langton's Ant is
a two-dimensional cellular automaton that is named after its creator, Chris
Langton. See the Details
section for more specific information about
the algorithm used in this function.
canvas_ant( colors, background = "#fafafa", iterations = 1000000, resolution = 500 )
canvas_ant( colors, background = "#fafafa", iterations = 1000000, resolution = 500 )
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. |
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. |
The algorithm for Langton's Ant involves the following steps:
Set up a two-dimensional grid of cells, where each cell can either be "colored" or "non-colored." The initial state of the grid is usually a single non-colored cell in the center of the grid.
Place an "ant" on the grid at the position of the initial non-colored cell. The ant can move in four directions: up, down, left, or right.
At each step of the algorithm, the ant examines the color of the cell it is currently on. If the cell is non-colored, the ant turns 90 degrees clockwise, colors the cell, and moves forward one unit.
If the cell is colored, the ant turns 90 degrees counterclockwise, uncolors the cell, and moves forward one unit.
The ant continues to move around the grid, following these rules at each step. If a certain number of iterations has passed, the ant chooses a different color which corresponds to a different combination of these rules.
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Langtons_ant
colorPalette
set.seed(1) # Simple example canvas_ant(colors = colorPalette("house"))
set.seed(1) # Simple example canvas_ant(colors = colorPalette("house"))
This function draws Blacklights on a canvas using a Support Vector Machine (SVM) algorithm. SVM's are a type of supervised learning algorithm that can be used for classification and regression purposes. The main goal of the SVM technique is to find a hyperplane (decision boundary) that best separates the values in the training dataset. This function draws the predictions from the SVM algorithm fitted on a randomly generated continuous training data set.
canvas_blacklight( colors, n = 1000, resolution = 500 )
canvas_blacklight( colors, n = 1000, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
n |
a positive integer specifying the number of random data points to generate. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Support-vector_machine
colorPalette
set.seed(1) # Simple example canvas_blacklight(colors = colorPalette("tuscany2"))
set.seed(1) # Simple example canvas_blacklight(colors = colorPalette("tuscany2"))
This function draws Chladni figures on a canvas. Named after Ernst Chladni, an 18th century physicist who first discovered them, Chladni figures are patterns that arise from the vibrations of a two-dimensional plate, typically covered with a thin layer of sand or powder. The Chladni figures are created by varying the frequency of vibration applied to the plate. In this implementation, the grid underneath the plate can be transformed using a domain warping technique. The basic idea behind domain warping is to apply a series of transformations to the input grid to create a more complex and interesting output.
canvas_chladni( colors, waves = 5, warp = 0, resolution = 500, angles = NULL, distances = NULL, flatten = FALSE )
canvas_chladni( colors, waves = 5, warp = 0, resolution = 500, angles = NULL, distances = NULL, flatten = FALSE )
colors |
a string or character vector specifying the color(s) used for the artwork. |
waves |
a character specifying the number of randomly sampled waves, or an integer vector of waves to be summed. |
warp |
a numeric value specifying the maximum warping distance
for each point. If |
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. |
angles |
optional, a resolution x resolution matrix containing the
angles for the warp, or a character indicating the type of noise to use
( |
distances |
optional, a resolution x resolution matrix containing the
distances for the warp, or a character indicating the type of noise to use
( |
flatten |
logical, should colors be flattened after being assigned to a point. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(2) # Simple example canvas_chladni(colors = colorPalette("origami")) # Advanced example canvas_chladni( colors = colorPalette("lava"), waves = c(1, 2, 3, 9), warp = 1 )
set.seed(2) # Simple example canvas_chladni(colors = colorPalette("origami")) # Advanced example canvas_chladni( colors = colorPalette("lava"), waves = c(1, 2, 3, 9), warp = 1 )
This function draws a circle map on a canvas. A circle map is a nonlinear dynamic system that can exhibit a phenomenon known as Arnold's tongue: a visualization of the frequency-locking behavior of a nonlinear oscillator with a periodic external force. The tongue is a region in the parameter space of the oscillator where the frequency of the oscillator matches the frequency of the external force. The tongue appears as a series of tongues of varying widths and shapes that can extend into regions of the parameter space where the frequency locking does not occur.
canvas_circlemap( colors, left = 0, right = 12.56, bottom = 0, top = 1, iterations = 10, resolution = 1500 )
canvas_circlemap( colors, left = 0, right = 12.56, bottom = 0, top = 1, iterations = 10, resolution = 1500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
left |
a value specifying the minimum location on the x-axis. |
right |
a value specifying the maximum location on the x-axis. |
bottom |
a value specifying the minimum location on the y-axis. |
top |
a value specifying the maximum location on the y-axis. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Arnold_tongue
https://linas.org/art-gallery/circle-map/circle-map.html
colorPalette
canvas_circlemap(colors = colorPalette("dark2"))
canvas_circlemap(colors = colorPalette("dark2"))
This function draws a cobweb on the canvas. The cobweb consists of many Fibonacci spirals shifted by random noise from a normal distribution. A Fibonacci spiral is a logarithmic spiral that is derived from the Fibonacci sequence, a mathematical sequence where each number is the sum of the two preceding ones. The spiral is created by connecting the corners of squares that are sized according to the Fibonacci sequence. Specifically, if we draw a sequence of squares with side lengths of 1, 1, 2, 3, 5, 8, 13, and so on, each square can be arranged so that it is tangent to the previous square at a corner. When we connect these corners with a smooth curve, the resulting shape is the Fibonacci spiral.
canvas_cobweb( colors, background = "#fafafa", lines = 300, iterations = 100 )
canvas_cobweb( colors, background = "#fafafa", lines = 300, iterations = 100 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
lines |
the number of lines to draw. |
iterations |
the number of iterations of the algorithm. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_cobweb(colors = colorPalette("neon1"), background = "black")
set.seed(1) # Simple example canvas_cobweb(colors = colorPalette("neon1"), background = "black")
This function draws the Collatz conjecture on a canvas. The
conjecture of the Collatz sequence is that no matter what positive integer
is chosen as the starting point of the sequence, the sequence will
eventually reach the number 1. This conjecture has been verified for all
starting integers up to very large numbers, but it has not been proven
mathematically. Despite its simple rule, the sequence can produce long and
complicated chains of numbers before eventually reaching 1. See the
Details
section for more specific information about the algorithm
used in this function.
canvas_collatz( colors, background = "#fafafa", n = 200, angle.even = 0.0075, angle.odd = 0.0145, side = FALSE )
canvas_collatz( colors, background = "#fafafa", n = 200, angle.even = 0.0075, angle.odd = 0.0145, side = FALSE )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
n |
a positive integer specifying the number of random starting integers to use for the lines. Can also be a vector of numbers to use as starting numbers. |
angle.even |
a value specifying the angle (in radials) to use in bending the sequence at each even number. |
angle.odd |
a value specifying the angle (in radials) to use in bending the sequence at each odd number. |
side |
logical. Whether to put the artwork on its side. |
The Collatz sequence, also known as the 3n+1
problem, is a
sequence of numbers generated by the following rule:
Start with any positive integer n
.
If n
is even, divide it by 2.
If n
is odd, multiply it by 3 and add 1.
Repeat this process with the new value of n
, generating a new
number in the sequence.
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://nl.wikipedia.org/wiki/Collatz_Conjecture
colorPalette
set.seed(1) # Simple example canvas_collatz(colors = colorPalette("tuscany3"))
set.seed(1) # Simple example canvas_collatz(colors = colorPalette("tuscany3"))
This function draws diamonds on a canvas and (optionally) places two lines behind them. The diamonds can be transparent or have a random color sampled from the input.
canvas_diamonds( colors, background = "#fafafa", col.line = "black", radius = 10, alpha = 1, p = 0.2, resolution = 500 )
canvas_diamonds( colors, background = "#fafafa", col.line = "black", radius = 10, alpha = 1, p = 0.2, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
col.line |
a character specifying the color of the diamond borders. |
radius |
a positive value specifying the radius of the diamonds. |
alpha |
a value specifying the transparency of the diamonds. If |
p |
a value specifying the probability of drawing an empty diamond. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_diamonds(colors = colorPalette("tuscany1"))
set.seed(1) # Simple example canvas_diamonds(colors = colorPalette("tuscany1"))
This function implements the fractal flame algorithm.
canvas_flame( colors, background = "#000000", iterations = 1000000, variations = 0, symmetry = 0, blend = TRUE, weighted = FALSE, post = FALSE, final = FALSE, extra = FALSE, display = c("colored", "logdensity"), zoom = 1, resolution = 1000, gamma = 1 )
canvas_flame( colors, background = "#000000", iterations = 1000000, variations = 0, symmetry = 0, blend = TRUE, weighted = FALSE, post = FALSE, final = FALSE, extra = FALSE, display = c("colored", "logdensity"), zoom = 1, resolution = 1000, gamma = 1 )
colors |
a string or 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. Using more iterations results in images of higher quality but also increases the computation time. |
variations |
an integer (vector) with a minimum of 0 and a maximum of 48 specifying the variations to be included in the flame. The default |
symmetry |
an integer with a minimum of -6 and a maximum of 6 indicating the type of symmetry to include in the flame. The default |
blend |
logical. Whether to blend the variations ( |
weighted |
logical. Whether to weigh the functions and the variations ( |
post |
logical. Whether to apply a post transformation in each iteration. |
final |
logical. Whether to apply a final transformation in each iteration. |
extra |
logical. Whether to apply an additional post transformation after the final transformation. Only has an effect when |
display |
a character indicating how to display the flame. |
zoom |
a positive value specifying the amount of zooming. |
resolution |
resolution of the artwork in pixels per row/column. Increasing the resolution does not increases the computation time of this algorithm. |
gamma |
a numeric value specifying the gamma correction (only used when |
The variation
argument can be used to include specific variations into the flame. See the appendix in the references for examples of all variations. Possible variations are:
0
: Linear (default)
1
: Sinusoidal
2
: Spherical
3
: Swirl
4
: Horsehoe
5
: Polar
6
: Handkerchief
7
: Heart
8
: Disc
9
: Spiral
10
: Hyperbolic
11
: Diamond
12
: Ex
13
: Julia
14
: Bent
15
: Waves
16
: Fisheye
17
: Popcorn
18
: Exponential
19
: Power
20
: Cosine
21
: Rings
22
: Fan
23
: Blob
24
: PDJ
25
: Fan2
26
: Rings2
27
: Eyefish
28
: Bubble
29
: Cylinder
30
: Perspective
31
: Noise
32
: JuliaN
33
: JuliaScope
34
: Blur
35
: Gaussian
36
: RadialBlur
37
: Pie
38
: Ngon
39
: Curl
40
: Rectangles
41
: Arch
42
: Tangent
43
: Square
44
: Rays
45
: Blade
46
: Secant
47
: Twintrian
48
: Cross
The symmetry
argument can be used to include symmetry into the flame. Possible options are:
0
: No symmetry (default)
-1
: Dihedral symmetry
1
: Two-way rotational symmetry
(-)2
: (Dihedral) Three-way rotational symmetry
(-)3
: (Dihedral) Four-way rotational symmetry
(-)4
: (Dihedral) Five-way rotational symmetry
(-)5
: (Dihedral) Six-way rotational symmetry
(-)6
: (Dihedral) Snowflake symmetry
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://flam3.com/flame_draves.pdf
colorPalette
set.seed(3) # Simple example, linear variation, relatively few iterations canvas_flame(colors = c("dodgerblue", "green"), variations = 0) # Simple example, linear variation, dihedral symmetry canvas_flame(colors = c("hotpink", "yellow"), variations = 0, symmetry = -1, iterations = 1e7) # Advanced example (no-blend, weighted, sinusoidal and spherical variations) canvas_flame( colors = colorPalette("origami"), variations = c(1, 2), blend = FALSE, weighted = TRUE, iterations = 1e8 ) # More iterations give much better images set.seed(123) canvas_flame(colors = c("red", "blue"), iterations = 1e8, variations = c(10, 17))
set.seed(3) # Simple example, linear variation, relatively few iterations canvas_flame(colors = c("dodgerblue", "green"), variations = 0) # Simple example, linear variation, dihedral symmetry canvas_flame(colors = c("hotpink", "yellow"), variations = 0, symmetry = -1, iterations = 1e7) # Advanced example (no-blend, weighted, sinusoidal and spherical variations) canvas_flame( colors = colorPalette("origami"), variations = c(1, 2), blend = FALSE, weighted = TRUE, iterations = 1e8 ) # More iterations give much better images set.seed(123) canvas_flame(colors = c("red", "blue"), iterations = 1e8, variations = c(10, 17))
This function draws flow fields on a canvas. The algorithm simulates the flow of points through a field of angles which can be set manually or generated from the predictions of a supervised learning method (i.e., knn, svm, random forest) trained on randomly generated data.
canvas_flow( colors, background = "#fafafa", lines = 500, lwd = 0.05, iterations = 100, stepmax = 0.01, outline = c("none", "circle", "square"), polar = FALSE, angles = NULL )
canvas_flow( colors, background = "#fafafa", lines = 500, lwd = 0.05, iterations = 100, stepmax = 0.01, outline = c("none", "circle", "square"), polar = FALSE, angles = NULL )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
lines |
the number of lines to draw. |
lwd |
expansion factor for the line width. |
iterations |
the maximum number of iterations for each line. |
stepmax |
the maximum proportion of the canvas covered in each iteration. |
outline |
character. Which outline to use for the artwork. Possible options are |
polar |
logical. Whether to draw the flow field with polar coordinates. |
angles |
optional, a 200 x 200 matrix containing the angles in the flow field, or a character indicating the type of noise to use ( |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://tylerxhobbs.com/essays/2020/flow-fields
colorPalette
set.seed(1) # Simple example canvas_flow(colors = colorPalette("dark2")) # Outline example canvas_flow( colors = colorPalette("vrolik1"), lines = 10000, outline = "circle", iterations = 10, angles = "svm" ) # Polar example canvas_flow( colors = colorPalette("vrolik2"), lines = 300, lwd = 0.5, polar = TRUE ) # Advanced example angles <- matrix(0, 200, 200) angles[1:100, ] <- seq(from = 0, to = 2 * pi, length = 100) angles[101:200, ] <- seq(from = 2 * pi, to = 0, length = 100) angles <- angles + rnorm(200 * 200, sd = 0.1) canvas_flow( colors = colorPalette("tuscany1"), background = "black", angles = angles, lwd = 0.4, lines = 1000, stepmax = 0.001 )
set.seed(1) # Simple example canvas_flow(colors = colorPalette("dark2")) # Outline example canvas_flow( colors = colorPalette("vrolik1"), lines = 10000, outline = "circle", iterations = 10, angles = "svm" ) # Polar example canvas_flow( colors = colorPalette("vrolik2"), lines = 300, lwd = 0.5, polar = TRUE ) # Advanced example angles <- matrix(0, 200, 200) angles[1:100, ] <- seq(from = 0, to = 2 * pi, length = 100) angles[101:200, ] <- seq(from = 2 * pi, to = 0, length = 100) angles <- angles + rnorm(200 * 200, sd = 0.1) canvas_flow( colors = colorPalette("tuscany1"), background = "black", angles = angles, lwd = 0.4, lines = 1000, stepmax = 0.001 )
This function draws the predictions from a random forest algorithm trained on randomly generated categorical data.
canvas_forest( colors, n = 1000, resolution = 500 )
canvas_forest( colors, n = 1000, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
n |
a positive integer specifying the number of random data points to generate. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Random_forest
colorPalette
set.seed(1) # Simple example canvas_forest(colors = colorPalette("jungle"))
set.seed(1) # Simple example canvas_forest(colors = colorPalette("jungle"))
This function paints functions with random parameters on a canvas.
canvas_function( colors, background = "#fafafa", by = 0.01, polar = TRUE, formula = NULL )
canvas_function( colors, background = "#fafafa", by = 0.01, polar = TRUE, formula = NULL )
colors |
a string specifying the color used for the artwork. |
background |
a character specifying the color used for the background. |
by |
a value specifying the step size between consecutive points. |
polar |
logical. Whether to draw the function with polar coordinates. |
formula |
optional, a named list with 'x' and 'y' as structured in the example. If |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://github.com/cutterkom/generativeart
colorPalette
set.seed(10) # Simple example canvas_function(colors = colorPalette("tuscany1")) # Advanced example formula <- list( x = quote(x_i^2 - sin(y_i^2)), y = quote(y_i^3 - cos(x_i^2)) ) canvas_function(colors = "firebrick", formula = formula)
set.seed(10) # Simple example canvas_function(colors = colorPalette("tuscany1")) # Advanced example formula <- list( x = quote(x_i^2 - sin(y_i^2)), y = quote(y_i^3 - cos(x_i^2)) ) canvas_function(colors = "firebrick", formula = formula)
This function draws the predictions from a k-nearest neighbors algorithm trained on randomly generated continuous data.
canvas_gemstone( colors, n = 1000, resolution = 500 )
canvas_gemstone( colors, n = 1000, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
n |
a positive integer specifying the number of random data points to generate. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
colorPalette
set.seed(1) # Simple example canvas_gemstone(colors = colorPalette("dark3"))
set.seed(1) # Simple example canvas_gemstone(colors = colorPalette("dark3"))
This function draws lissajous curves with points connected via a k-nearest neighbor approach.
canvas_lissajous( colors, background = "#000000", iterations = 2, neighbors = 50, noise = FALSE )
canvas_lissajous( colors, background = "#000000", iterations = 2, neighbors = 50, noise = FALSE )
colors |
a string or 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. |
neighbors |
a positive integer specifying the number of neighbors a block considers when drawing the connections. |
noise |
logical. Whether to add perlin noise to the coordinates of the nodes. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Lissajous_curve
colorPalette
set.seed(13) # Simple example canvas_lissajous(colors = colorPalette("blossom"))
set.seed(13) # Simple example canvas_lissajous(colors = colorPalette("blossom"))
This function draws the Mandelbrot set and other related fractal sets on the canvas.
canvas_mandelbrot( colors, iterations = 100, zoom = 1, set = c("mandelbrot", "multibrot", "julia", "ship"), left = -2.16, right = 1.16, bottom = -1.66, top = 1.66, resolution = 500 )
canvas_mandelbrot( colors, iterations = 100, zoom = 1, set = c("mandelbrot", "multibrot", "julia", "ship"), left = -2.16, right = 1.16, bottom = -1.66, top = 1.66, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
zoom |
a positive value specifying the amount of zoom to apply. |
set |
a character indicating which fractal set to draw. Possible options are |
left |
a value specifying the minimum location on the x-axis. |
right |
a value specifying the maximum location on the x-axis. |
bottom |
a value specifying the minimum location on the y-axis. |
top |
a value specifying the maximum location on the y-axis. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Mandelbrot_set
colorPalette
canvas_mandelbrot(colors = colorPalette("tuscany1"), set = "mandelbrot") canvas_mandelbrot(colors = colorPalette("flag"), set = "julia", zoom = 2)
canvas_mandelbrot(colors = colorPalette("tuscany1"), set = "mandelbrot") canvas_mandelbrot(colors = colorPalette("flag"), set = "julia", zoom = 2)
This function draws a maze on a canvas.
canvas_maze( color = "#fafafa", walls = "black", background = "#fafafa", resolution = 20, polar = FALSE )
canvas_maze( color = "#fafafa", walls = "black", background = "#fafafa", resolution = 20, polar = FALSE )
color |
a character specifying the color used for the artwork. |
walls |
a character specifying the color used for the walls of the maze. |
background |
a character specifying the color used for the background. |
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. |
polar |
logical, whether to use polar coordinates. Warning, this increases display and saving time dramatically. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://github.com/matfmc/mazegenerator
colorPalette
set.seed(1) # Simple example canvas_maze(color = "#fafafa")
set.seed(1) # Simple example canvas_maze(color = "#fafafa")
This function draws one or more rotating circular morphing meshes on the canvas.
canvas_mesh( colors, background = "#fafafa", transform = c("perlin", "fbm", "simplex", "cubic", "worley", "knn", "rf", "svm"), lines = 500, iterations = 500, mixprob = 0 )
canvas_mesh( colors, background = "#fafafa", transform = c("perlin", "fbm", "simplex", "cubic", "worley", "knn", "rf", "svm"), lines = 500, iterations = 500, mixprob = 0 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background (and the hole). |
transform |
a character specifying the type of transformation to use for the radius. |
lines |
an integer specifying the number of lines to darw. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
mixprob |
a value between 0 and 1 specifying the probability of a line segment getting another color. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://web.archive.org/web/20231130151102/http://rectangleworld.com/blog/archives/462
colorPalette
set.seed(2) # Simple example canvas_mesh(colors = colorPalette("origami"))
set.seed(2) # Simple example canvas_mesh(colors = colorPalette("origami"))
This function draws the predictions from a k-nearest neighbors algorithm trained on randomly generated categorical data.
canvas_mosaic( colors, n = 1000, resolution = 500 )
canvas_mosaic( colors, n = 1000, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
n |
a positive integer specifying the number of random data points to generate. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
colorPalette
set.seed(1) # Simple example canvas_mosaic(colors = colorPalette("retro2"))
set.seed(1) # Simple example canvas_mosaic(colors = colorPalette("retro2"))
This function creates an artwork from randomly generated k-nearest neighbors noise.
canvas_nebula( colors, k = 50, n = 500, resolution = 500 )
canvas_nebula( colors, k = 50, n = 500, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
k |
a positive integer specifying the number of nearest neighbors to consider. |
n |
a positive integer specifying the number of random data points to generate. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_nebula(colors = colorPalette("tuscany1"))
set.seed(1) # Simple example canvas_nebula(colors = colorPalette("tuscany1"))
This function uses a space colony algorithm to draw Petri dish colonies.
canvas_petri( colors, background = "#fafafa", dish = "black", attractors = 1000, iterations = 15, hole = 0 )
canvas_petri( colors, background = "#fafafa", dish = "black", attractors = 1000, iterations = 15, hole = 0 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background (and the hole). |
dish |
a character specifying the color used for the Petri dish. |
attractors |
an integer specifying the number of attractors. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
hole |
a value between 0 and 0.9 specifying the hole size in proportion to the dish. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://medium.com/@jason.webb/space-colonization-algorithm-in-javascript-6f683b743dc5
colorPalette
set.seed(2) # Simple example canvas_petri(colors = colorPalette("origami")) # Advanced example canvas_petri(colors = "white", hole = 0.8, attractors = 5000)
set.seed(2) # Simple example canvas_petri(colors = colorPalette("origami")) # Advanced example canvas_petri(colors = "white", hole = 0.8, attractors = 5000)
This function draws a phyllotaxis which resembles the arrangement of leaves on a plant stem.
canvas_phyllotaxis( colors, background = "#fafafa", iterations = 10000, angle = 137.5, size = 0.01, alpha = 1, p = 0.5 )
canvas_phyllotaxis( colors, background = "#fafafa", iterations = 10000, angle = 137.5, size = 0.01, alpha = 1, p = 0.5 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
iterations |
the number of iterations of the algorithm. |
angle |
the angle at which to place the artwork. |
size |
the size of the lines. |
alpha |
transparency of the points. |
p |
probability of drawing a point on each iteration. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Phyllotaxis
colorPalette
set.seed(1) # Simple example canvas_phyllotaxis(colors = colorPalette("tuscany1"))
set.seed(1) # Simple example canvas_phyllotaxis(colors = colorPalette("tuscany1"))
This function paints one or multiple planets and uses a cellular automata to fill their surfaces.
canvas_planet( colors, threshold = 4, iterations = 200, starprob = 0.01, fade = 0.2, radius = NULL, center.x = NULL, center.y = NULL, light.right = TRUE, resolution = 1500 )
canvas_planet( colors, threshold = 4, iterations = 200, starprob = 0.01, fade = 0.2, radius = NULL, center.x = NULL, center.y = NULL, light.right = TRUE, resolution = 1500 )
colors |
a character specifying the colors used for a single planet. Can also be a list where each entry is a vector of colors for a planet. |
threshold |
a character specifying the threshold for a color take. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
starprob |
a value specifying the probability of drawing a star in outer space. |
fade |
a value specifying the amount of fading to apply. |
radius |
a numeric (vector) specifying the radius of the planet(s). |
center.x |
the x-axis coordinate(s) for the center(s) of the planet(s). |
center.y |
the y-axis coordinate(s) for the center(s) of the planet(s). |
light.right |
whether to draw the light from the right or the left. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://fronkonstin.com/2021/01/02/neighborhoods-experimenting-with-cyclic-cellular-automata/
set.seed(1) # Simple example canvas_planet(colors = colorPalette("lava"), threshold = 3) # Advanced example colors <- list( c("khaki1", "lightcoral", "lightsalmon"), c("dodgerblue", "forestgreen", "white"), c("gray", "darkgray", "beige") ) canvas_planet(colors, radius = c(800, 400, 150), center.x = c(1, 500, 1100), center.y = c(1400, 500, 1000), starprob = 0.005 )
set.seed(1) # Simple example canvas_planet(colors = colorPalette("lava"), threshold = 3) # Advanced example colors <- list( c("khaki1", "lightcoral", "lightsalmon"), c("dodgerblue", "forestgreen", "white"), c("gray", "darkgray", "beige") ) canvas_planet(colors, radius = c(800, 400, 150), center.x = c(1, 500, 1100), center.y = c(1400, 500, 1000), starprob = 0.005 )
This function draws many points on the canvas and connects these points into a polygon. After repeating this for all the colors, the edges of all polygons are drawn on top of the artwork.
canvas_polylines( colors, background = "#fafafa", ratio = 0.5, iterations = 1000, size = 0.1, resolution = 500 )
canvas_polylines( colors, background = "#fafafa", ratio = 0.5, iterations = 1000, size = 0.1, resolution = 500 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the lines. |
ratio |
a positive value specifying the width of the polygons. Larger ratios cause more overlap. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
size |
a positive value specifying the size of the borders. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_polylines(colors = colorPalette("retro1"))
set.seed(1) # Simple example canvas_polylines(colors = colorPalette("retro1"))
This function draws Recaman's sequence on a canvas. The algorithm takes increasingly large steps backward on the positive number line, but if it is unable to it takes a step forward.
canvas_recaman( colors, background = "#fafafa", iterations = 100, start = 0, increment = 1, curvature = 1, angle = 0, size = 0.1, closed = FALSE )
canvas_recaman( colors, background = "#fafafa", iterations = 100, start = 0, increment = 1, curvature = 1, angle = 0, size = 0.1, closed = FALSE )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
iterations |
the number of iterations of the algorithm. |
start |
the starting point of the algorithm. |
increment |
the increment of each step. |
curvature |
the curvature of each line. |
angle |
the angle at which to place the artwork. |
size |
the size of the lines. |
closed |
logical. Whether to plot a curve from the end of the sequence back to the starting point. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://mathworld.wolfram.com/RecamansSequence.html
colorPalette
set.seed(1) # Simple example canvas_recaman(colors = colorPalette("tuscany1"))
set.seed(1) # Simple example canvas_recaman(colors = colorPalette("tuscany1"))
This function paints random ribbons and (optionally) a triangle in the middle.
canvas_ribbons( colors, background = "#fdf5e6", triangle = TRUE )
canvas_ribbons( colors, background = "#fdf5e6", triangle = TRUE )
colors |
a string or character vector specifying the color(s) used for the artwork. The number of colors determines the number of ribbons. |
background |
a character specifying the color of the background. |
triangle |
logical. Whether to draw the triangle that breaks the ribbon polygons. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_ribbons(colors = colorPalette("retro1"))
set.seed(1) # Simple example canvas_ribbons(colors = colorPalette("retro1"))
This function draws line segments on a canvas. The length and direction of the line segments is determined randomly.
canvas_segments( colors, background = "#fafafa", n = 250, p = 0.5, H = 0.1, size = 0.2 )
canvas_segments( colors, background = "#fafafa", n = 250, p = 0.5, H = 0.1, size = 0.2 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background. |
n |
a positive integer specifying the number of line segments to draw. |
p |
a value specifying the probability of drawing a vertical line segment. |
H |
a positive value specifying the scaling factor for the line segments. |
size |
a positive value specifying the size of the line segments. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_segments(colors = colorPalette("dark1"))
set.seed(1) # Simple example canvas_segments(colors = colorPalette("dark1"))
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 )
canvas_slime( colors, background = "#000000", iterations = 2000, agents = 1000, layout = c( "random", "gaussian", "circle", "grid", "clusters", "arrows", "wave", "spiral" ), resolution = 1000 )
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 |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://cargocollective.com/sagejenson/physarum
https://fronkonstin.com/2020/08/11/abstractions/
colorPalette
set.seed(1) # Simple example canvas_slime(colors = colorPalette("neon1"))
set.seed(1) # Simple example canvas_slime(colors = colorPalette("neon1"))
This function implements the rainbow smoke algorithm.
canvas_smoke( colors, init = 1, shape = c("bursts", "clouds"), algorithm = c("minimum", "average"), resolution = 150 )
canvas_smoke( colors, init = 1, shape = c("bursts", "clouds"), algorithm = c("minimum", "average"), resolution = 150 )
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 |
shape |
a character indicating the shape of the smoke. Possible options are |
algorithm |
a character specifying how to select a new pixel. The default option |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
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)
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)
This function draws split lines.
canvas_splits( colors, background = "#fafafa", iterations = 6, sd = 0.2, lwd = 0.05, alpha = 0.5 )
canvas_splits( colors, background = "#fafafa", iterations = 6, sd = 0.2, lwd = 0.05, alpha = 0.5 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the background (and the hole). |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
sd |
a numeric value specifying the standard deviation of the angle noise. |
lwd |
a numeric value specifying the width of the lines. |
alpha |
a numeric value specifying the transparency of the lines. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(2) # Simple example canvas_splits(colors = "black", sd = 0) # Simple example canvas_splits(colors = colorPalette("dark2"), background = "black", sd = 1)
set.seed(2) # Simple example canvas_splits(colors = "black", sd = 0) # Simple example canvas_splits(colors = colorPalette("dark2"), background = "black", sd = 1)
This function paints random squares and rectangles. It works by repeatedly cutting into the canvas at random locations and coloring the area that these cuts create.
canvas_squares( colors, background = "#000000", cuts = 50, ratio = 1.618, resolution = 200, noise = FALSE )
canvas_squares( colors, background = "#000000", cuts = 50, ratio = 1.618, resolution = 200, noise = FALSE )
colors |
a string or character vector specifying the color(s) used for the artwork. |
background |
a character specifying the color used for the borders of the squares. |
cuts |
a positive integer specifying the number of cuts to make. |
ratio |
a value specifying the |
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. |
noise |
logical. Whether to add k-nn noise to the artwork. Note that adding noise increases computation time significantly in large dimensions. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_squares(colors = colorPalette("retro2"))
set.seed(1) # Simple example canvas_squares(colors = colorPalette("retro2"))
This function creates a brownian motion on each row of the artwork and colors it according to the height of the motion.
canvas_stripes( colors, n = 300, H = 1, burnin = 1 )
canvas_stripes( colors, n = 300, H = 1, burnin = 1 )
colors |
a string or character vector specifying the color(s) used for the artwork. |
n |
a positive integer specifying the length of the brownian motion (effectively the width of the artwork). |
H |
a positive value specifying the square of the standard deviation of each step in the motion. |
burnin |
a positive integer specifying the number of steps to discard before filling each row. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_stripes(colors = colorPalette("random", n = 10))
set.seed(1) # Simple example canvas_stripes(colors = colorPalette("random", n = 10))
This function creates an artwork that resembles paints strokes. The algorithm is based on the simple idea that each next point on the grid has a chance to take over the color of an adjacent colored point but also has a change of generating a new color.
canvas_strokes( colors, neighbors = 1, p = 0.01, iterations = 1, resolution = 500, side = FALSE )
canvas_strokes( colors, neighbors = 1, p = 0.01, iterations = 1, resolution = 500, side = FALSE )
colors |
a string or character vector specifying the color(s) used for the artwork. |
neighbors |
a positive integer specifying the number of neighbors a block considers when taking over a color. More neighbors fades the artwork. |
p |
a value specifying the probability of selecting a new color at each block. A higher probability adds more noise to the artwork. |
iterations |
a positive integer specifying the number of iterations of the algorithm. More iterations generally apply more fade to the artwork. |
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. |
side |
logical. Whether to put the artwork on its side. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
colorPalette
set.seed(1) # Simple example canvas_strokes(colors = colorPalette("tuscany1"))
set.seed(1) # Simple example canvas_strokes(colors = colorPalette("tuscany1"))
This function draws swirling stripes on a canvas by simulating a particle system.
canvas_swirls( colors, background = "#fafafa", iterations = 250, n = 250, curvature = 0.005, lwd = 0.1, resolution = 500 )
canvas_swirls( colors, background = "#fafafa", iterations = 250, n = 250, curvature = 0.005, lwd = 0.1, resolution = 500 )
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. |
n |
a positive integer specifying the number of particles. |
curvature |
a positive number specifying the curvature of the lines. Larger values imply relatively curved lines, while lower values produce relatively straight lines. |
lwd |
expansion factor for the line width. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://mattdesl.svbtle.com/generative-art-with-nodejs-and-canvas
colorPalette
set.seed(2) # Simple example canvas_swirls(colors = colorPalette("origami"))
set.seed(2) # Simple example canvas_swirls(colors = colorPalette("origami"))
This function uses a reaction diffusion algorithm in an attempt to draw a Portuguese-styled tiling pattern.
canvas_tiles( colors, background = "#ffffff", iterations = 1000, size = 5, col.line = "#000000", resolution = 100, layout = NULL )
canvas_tiles( colors, background = "#ffffff", iterations = 1000, size = 5, col.line = "#000000", resolution = 100, layout = NULL )
colors |
a string or character vector specifying the color(s) used for the artwork, or a list containing a set of colors for each unique tile on the wall. |
background |
a character specifying the color of the background. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
size |
a positive integer specifying how many tiles should be in each row of the wall. |
col.line |
a character specifying the color of the joints between the tiles. |
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. |
layout |
optional. A matrix containing integers ranging from 1 to the maximum number of unique tiles (i.e., |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Reaction–diffusion_system
colorPalette
set.seed(3) # Simple example canvas_tiles(colors = colorPalette("azul"), iterations = 5000) # Advanced example canvas_tiles(colors = list( colorPalette("blossom"), colorPalette("neon1"), colorPalette("dark1") )) # Custom layout layout <- matrix(c( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), nrow = 11, byrow = TRUE) canvas_tiles( colors = list(colorPalette("azul"), colorPalette("blossom")), size = nrow(layout), layout = layout ) # Another custom layout set.seed(11) layout <- matrix(c( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 3, 3, 2, 2, 4, 4, 4, 2, 5, 5, 5, 2, 6, 2, 6, 2, 2, 1, 2, 1, 2, 3, 2, 3, 2, 2, 4, 2, 2, 5, 2, 2, 2, 6, 2, 6, 2, 2, 1, 1, 1, 2, 3, 3, 2, 2, 2, 4, 2, 2, 2, 5, 2, 2, 2, 6, 2, 2, 2, 1, 2, 1, 2, 3, 2, 3, 2, 2, 4, 2, 5, 5, 5, 2, 2, 2, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), nrow = 21, byrow = TRUE) canvas_tiles( colors = list( colorPalette("blossom"), colorPalette("azul"), colorPalette("neon1"), colorPalette("mixer4"), colorPalette("neon2"), colorPalette("vrolik1"), colorPalette("blackwhite") ), iterations = 2000, size = nrow(layout), layout = layout )
set.seed(3) # Simple example canvas_tiles(colors = colorPalette("azul"), iterations = 5000) # Advanced example canvas_tiles(colors = list( colorPalette("blossom"), colorPalette("neon1"), colorPalette("dark1") )) # Custom layout layout <- matrix(c( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), nrow = 11, byrow = TRUE) canvas_tiles( colors = list(colorPalette("azul"), colorPalette("blossom")), size = nrow(layout), layout = layout ) # Another custom layout set.seed(11) layout <- matrix(c( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 3, 3, 2, 2, 4, 4, 4, 2, 5, 5, 5, 2, 6, 2, 6, 2, 2, 1, 2, 1, 2, 3, 2, 3, 2, 2, 4, 2, 2, 5, 2, 2, 2, 6, 2, 6, 2, 2, 1, 1, 1, 2, 3, 3, 2, 2, 2, 4, 2, 2, 2, 5, 2, 2, 2, 6, 2, 2, 2, 1, 2, 1, 2, 3, 2, 3, 2, 2, 4, 2, 5, 5, 5, 2, 2, 2, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), nrow = 21, byrow = TRUE) canvas_tiles( colors = list( colorPalette("blossom"), colorPalette("azul"), colorPalette("neon1"), colorPalette("mixer4"), colorPalette("neon2"), colorPalette("vrolik1"), colorPalette("blackwhite") ), iterations = 2000, size = nrow(layout), layout = layout )
This function paints a turmite. A turmite is a Turing machine which has an orientation in addition to a current state and a "tape" that consists of a two-dimensional grid of cells.
canvas_turmite( colors, background = "#fafafa", p = 0, iterations = 1000000, resolution = 500, noise = FALSE )
canvas_turmite( colors, background = "#fafafa", p = 0, iterations = 1000000, resolution = 500, noise = FALSE )
colors |
a character specifying the color used for the artwork. The number of colors determines the number of turmites. |
background |
a character specifying the color used for the background. |
p |
a value specifying the probability of a state switch within the turmite. |
iterations |
a positive integer specifying the number of iterations of the algorithm. |
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. |
noise |
logical. Whether to add k-nn noise to the artwork. Note that adding noise increases computation time significantly in large dimensions. |
The turmite algorithm consists of the following steps: 1) turn on the spot (left, right, up, down) 2) change the color of the square 3) move forward one square.
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://en.wikipedia.org/wiki/Turmite
colorPalette
set.seed(1) # Simple example canvas_turmite(colors = colorPalette("dark2"))
set.seed(1) # Simple example canvas_turmite(colors = colorPalette("dark2"))
This function paints watercolors on a canvas.
canvas_watercolors( colors, background = "#fafafa", layers = 50, depth = 2, resolution = 250 )
canvas_watercolors( colors, background = "#fafafa", layers = 50, depth = 2, resolution = 250 )
colors |
a string specifying the color used for the artwork. |
background |
a character specifying the color used for the background. |
layers |
the number of layers of each color. |
depth |
the maximum depth of the recursive algorithm. |
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. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]
https://tylerxhobbs.com/essays/2017/a-generative-approach-to-simulating-watercolor-paints
colorPalette
set.seed(1) # Simple example canvas_watercolors(colors = colorPalette("tuscany2"))
set.seed(1) # Simple example canvas_watercolors(colors = colorPalette("tuscany2"))
This function creates a random color palette, or allows the user to select a pre-implemented palette.
colorPalette( name, n = NULL )
colorPalette( name, n = NULL )
name |
name of the color palette. Can be |
n |
the number of colors to select from the palette. Required if |
The following color palettes are implemented:
A vector of colors.
Koen Derks, [email protected]
colorPalette("divergent", 5)
colorPalette("divergent", 5)
This function is a wrapper around ggplot2::ggsave
. It provides a suggested export with square dimensions for a canvas created using the aRtsy
package.
saveCanvas(plot, filename, width = 7, height = 7, dpi = 300)
saveCanvas(plot, filename, width = 7, height = 7, dpi = 300)
plot |
a ggplot2 object to be saved. |
filename |
the filename of the export. |
width |
the width of the artwork in cm. |
height |
the height of the artwork in cm. |
dpi |
the |
No return value, called for saving plots.
Koen Derks, [email protected]
Add a canvas theme to the plot. The canvas theme by default has no margins and fills any empty canvas with a background color.
theme_canvas(x, background = NULL, margin = 0)
theme_canvas(x, background = NULL, margin = 0)
x |
a ggplot2 object. |
background |
a character specifying the color used for the empty canvas. |
margin |
margins of the canvas. |
A ggplot
object containing the artwork.
Koen Derks, [email protected]