`R`

and `ggplot2`

*“If you laugh at a joke, what difference does it make if subsequently you are told that the joke was created by an algorithm?” - Marcus du Sautoy, The Creative Code*

`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.

Good luck hunting for some good `seed`

’s!

Every 24 hours this repository randomly generates and tweets an artwork from the `aRtsy`

library. The full collection of daily artworks is available on the aRtsy twitter feed. This is today’s artwork:

The most recently released version of `aRtsy`

can be downloaded from CRAN by running the following command in R:

Alternatively, you can download the development version from GitHub using:

After installation, the `aRtsy`

package can be loaded with:

**Note:** Render times in RStudio can be quite long for some artworks. It is therefore recommended that you save the artwork to a file (e.g., `.png`

or `.jpg`

) before viewing it. You can save the artwork in an appropriate size and quality using the `saveCanvas()`

function.

```
artwork <- canvas_strokes(colors = c("black", "white"))
saveCanvas(artwork, filename = "myArtwork.png")
```

*The Iterative collection*

`canvas_ant()`

`canvas_collatz()`

`canvas_flow()`

`canvas_maze()`

`canvas_planet()`

`canvas_stripes()`

`canvas_strokes()`

`canvas_turmite()`

`canvas_watercolors()`

*The Geometric collection*

`canvas_diamonds()`

`canvas_function()`

`canvas_polylines()`

`canvas_ribbons()`

`canvas_segments()`

`canvas_squares()`

*The Supervised collection*

*The Static collection*

The Iterative collection implements algorithms whose state depend on the previous state. These algorithms mostly use a grid based canvas to draw on. On this grid, each point represents a pixel of the final image. By assigning a color to these points according to certain rules, one can create the images in this collection.

According to Wikipedia, Langton’s ant is a turmite with a very specific set of rules. In particular, after choosing a starting position the algorithm involves repeating the following three rules:

- On a non-colored block: turn 90 degrees clockwise, un-color the block, move forward one block,
- On a colored block: turn 90 degrees counter-clockwise, color the block, move forward one block,
- If a certain number of iterations has passed, choose a different color which corresponds to a different combination of these rules.

You can use the `canvas_ant()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_ant(colors = colorPalette("house"))
# see ?canvas_ant for more input parameters of this algorithm
```

The Collatz conjecture is also known as the `3x+1`

equation. The algorithm draws lines according to a simple rule set:

- Take a random positive number.
- If the number is even, divide it by 2.
- If the number is odd, multiply the number by 3 and add 1.
- Repeat to get a sequence of numbers.

By visualizing the sequence for each number, overlaying sequences that are the same, and bending the edges differently for even and odd numbers in the sequence, organic looking structures can occur.

You can use the `canvas_collatz()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_collatz(colors = colorPalette("tuscany3"))
# see ?canvas_collatz for more input parameters of this algorithm
```

This artwork implements a version of the algorithm described in the blog post Flow Fields by Tyler Hobbs. It works by creating a grid of angles and determining how certain points will flow through this field. The angles in the field can be set manually or according to the predictions of a supervised learning method trained on randomly generated data.

You can use the `canvas_flow()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_flow(colors = colorPalette("dark2"))
# see ?canvas_flow for more input parameters of this algorithm
```

This artwork creates mazes. The mazes are created using a random walk algorithm (described in the mazegenerator repository). The mazes can also be displayed with polar coordinates, creating some pretty cool effects.

You can use the `canvas_maze()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_maze(color = "#fafafa")
# see ?canvas_maze for more input parameters of this algorithm
```

We all love space, and this type of artwork puts you right between the planets. The algorithm creates one or multiple planets in space and uses a cellular automata (described in the blog post Neighborhoods: Experimenting with Cyclic Cellular Automata by Antonio Sánchez Chinchón) to fill in their surfaces. The color and placement of the planets can be set manually.

You can use the `canvas_planet()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_planet(colors = colorPalette("retro3"))
# see ?canvas_planet for more input parameters of this algorithm
```

This type of artwork is based on the concept of Brownian motion. The algorithm generates a sequence of slightly increasing and decreasing values for each row on the canvas. Next, it fills these according to their generated value. More colors usually make this artwork more interesting.

You can use the `canvas_stripes()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_stripes(colors = colorPalette("random", n = 10))
# see ?canvas_stripes for more input parameters of this algorithm
```

When you think of the act of painting, you probably imagine stroking paint on a canvas. This type of artwork tries to mimic that activity. The algorithm is based on the simple idea that each next point on a grid-based canvas has a chance to take over the color of an adjacent colored point, but also has a minor chance of generating a new color. Going over the canvas like this results in something that looks like strokes of paint.

You can use the `canvas_strokes()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_strokes(colors = colorPalette("tuscany1"))
# see ?canvas_strokes for more input parameters of this algorithm
```

According to Wikipedia, a turmite is *“a Turing machine which has an orientation in addition to a current state and a”tape" that consists of an infinite two-dimensional grid of cells"*. The classic algorithm consists of repeating the following three simple steps:

- Turn on the spot (left, right, up, or down),
- Change the color of the block,
- Move forward one block.

You can use the `canvas_turmite()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_turmite(colors = colorPalette("dark2"))
# see ?canvas_turmite for more input parameters of this algorithm
```

This artwork implements a version of the algorithm described in the blog post A Guide to Simulating Watercolor Paint with Generative Art by Tyler Hobbs. It works by layering several geometric shapes and deforming each shape by repeatedly splitting its edges.

You can use the `canvas_watercolors()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_watercolors(colors = colorPalette("tuscany2"))
# see ?canvas_watercolors for more input parameters of this algorithm
```

The Geometric collection mostly implements algorithms that draw a geometric shape and apply a random color to it.

This function creates a set of diamonds on a canvas. The diamonds are filled in (or left out) using a random color assignment.

You can use the `canvas_diamonds()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_diamonds(colors = colorPalette("tuscany1"))
# see ?canvas_diamonds for more input parameters of this algorithm
```

The idea for this type of artwork is taken over from the `generativeart`

package. In this algorithm, the position of every single point is calculated by a formula which has random parameters. You can supply your own formula.

You can use the `canvas_function()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_function(color = "navyblue")
# see ?canvas_function for more input parameters of this algorithm
```

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.

You can use the `canvas_polylines()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_polylines(colors = colorPalette("retro1"))
# see ?canvas_polylines for more input parameters of this algorithm
```

This function creates colored ribbons with (or without) a triangle that breaks their paths. This path of the ribbon polygon is creating by picking one point on the left side of the triangle and one point on the right side at random and using these points as nodes.

You can use the `canvas_ribbons()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_ribbons(colors = colorPalette("retro1")
# see ?canvas_ribbons for more input parameters of this algorithm
```

This type of artwork is inspired by the style of the well-known paintings by the Dutch artist Piet Mondriaan. The position and direction of each line segment is determined randomly.

You can use the `canvas_segments()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_segments(colors = colorPalette("dark1"))
# see ?canvas_segments for more input parameters of this algorithm
```

This artwork uses a variety of squares and rectangles to fill the canvas. It works by repeatedly cutting into the canvas at random locations and coloring the area that these cuts create.

You can use the `canvas_squares()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_squares(colors = colorPalette("retro2"))
# see ?canvas_squares for more input parameters of this algorithm
```

The artworks in the Supervised collection are inspired by decision boundary plots in machine learning tasks. The algorithms in this collection work by generating random data points on a two dimensional surface (with either a continuous or a categorical response variable), which they then try to model using the supervised learning algorithm. Next, they try to predict the color of each pixel on the canvas.

This artwork is inspired by a supervised machine learning method called support vector machines. It applies the principle as described above using a continuous response variable to fill the color of the pixels.

You can use the `canvas_blacklight()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_blacklight(colors = colorPalette("random", n = 5))
# see ?canvas_blacklight for more input parameters of this algorithm
```

This artwork is inspired by a supervised learning method called random forest. It applies the principle as described above using a continuous response variable to fill the color of the pixels.

You can use the `canvas_forest()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_forest(colors = colorPalette("jungle"))
# see ?canvas_forest for more input parameters of this algorithm
```

This artwork is inspired by a supervised learning method called k-nearest neighbors. It applies the principle as described above using a continuous response variable to fill the color of the pixels. In short, the k-nearest neighbors algorithm computes the distance of each pixel on the canvas to each randomly generated data point and assigns it the color of the value of that data point.

You can use the `canvas_gemstone()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_gemstone(colors = colorPalette("dark3"))
# see ?canvas_gemstone for more input parameters of this algorithm
```

This artwork also uses a k-nearest neighbors method but instead of a continuous response variable a categorical one is used, making it a classification problem. If you considers fewer neighbors the artwork looks like a mosaic, while higher values make the artwork look more smooth.

You can use the `canvas_mosaic()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_mosaic(colors = colorPalette("retro2"))
# see ?canvas_mosaic for more input parameters of this algorithm
```

Based on the very same principle as described in the artwork above is this next type of artwork. However, it produces slightly different pictures as it uses different code to create a form of k-nearest neighbors noise. Some of these artworks can resemble nebulas in outer space.

You can use the `canvas_nebula()`

function to make your own artwork using this algorithm.

```
set.seed(1)
canvas_nebula(colors = colorPalette("tuscany1"))
# see ?canvas_nebula for more input parameters of this algorithm
```

The Static collection implements static images that produce nice pictures.

This type of artwork is based on the concept of an Arnold tongue. According to Wikipedia, Arnold tongues *“are a pictorial phenomenon that occur when visualizing how the rotation number of a dynamical system, or other related invariant property thereof, changes according to two or more of its parameters”*.

You can use the `canvas_circlemap()`

function to make your own artwork using this algorithm.

```
canvas_circlemap(colors = colorPalette("dark2"))
# see ?canvas_circlemap for more input parameters of this algorithm
```

This type of artwork visualizes the Mandelbrot set fractal, a perfect example of a complex structure arising from the application of simple rules. You can zoom in on the set and apply some color to create these nice images.

You can use the `canvas_mandelbrot()`

function to make your own artwork using this algorithm.

```
canvas_mandelbrot(colors = colorPalette("tuscany1"))
# see ?canvas_mandelbrot for more input parameters of this algorithm
```

The function `colorPalette()`

can be used to generate a random color palette, or pick a pre-implemented color palette. Currently, the color palettes displayed below are implemented in `aRtsy`

. Feel free to suggest or add a new palette by making an issue on GitHub!

`aRtsy`

packageContributions to the `aRtsy`

package are very much appreciated and you are free to suggest or add your own algorithms! If you want to add your own artwork to the package so that others can create unique versions of it, feel free to make a pull request to the GitHub repository. Don’t forget to also adjust generate-artwork.R if you want the artwork to show up in the ‘Artwork of the day’ category and the twitter feed.