# Tempest

### by Danielle Navarro, 06 Oct 2019

I’ve long admired generative artwork. There’s something appealing to me about writing a function that doesn’t merely generate a single image, but instead defines a family of images that you can then explore to discover artwork that surprises even you, the person who wrote the function. I’ve never been particularly skilled at it, but so what? The point of artwork isn’t really to be the “best” or even particularly “good” at doing a thing, it’s to take joy in the act of creation and discovery.

Inspired by Thomas Lin Pederson and Will Chase who have been making beautiful things in R based around curl noise, I wanted to see what I could do. So I wrote the jasmines::tempest() function, the source code for which is up on GitHub. The idea behind the function is to iteratively apply a curl noise transformation to a seed object, and visualise the results. At the moment I’m not really trying to understand the low level mechanics of how curl noise works, I just want to play around and see what I can make with it.

Here’s a simple example. The seed object here is a set of six horizontal “lines”, where each line is represented by a discrete set of points (i.e., seed_rows(n=6)). Each point is peturbed once (iterations = 1) according to a curl noise operation, and thin line (line_width = 1) is drawn connecting the original point to the peturbed one. The seed object is highlighted by by setting seed_col = "white":

library(jasmines)
tempest(
seed = seed_rows(n = 6),
seed_col = "white",
iterations = 1,
line_width = 1
)

The wavy shapes that this produces are the basic unit from which fancier calls to tempest() are built. The colouring of segments uses the viridis palette by default, though this can be customised. The specific mapping from segment to colour is a deterministic function of its length, but as you can see looking at the plot it’s not a particularly systematic one!

We can make the images more complicated by increasing the number of iterations. In the code below we start with three horizontal rows, apply the curl noise operation as before to output a set of peturbed points (and segments), and then repeat the process a second time, using the output from the first iteration as the input to the second iteration:

tempest(
seed = seed_rows(n = 3),
iterations = 2,
line_width = 1
)

At the moment the images aren’t all that pretty, but this “waves over waves” mechanic has a certain appeal, and it doesn’t take a lot of tinkering to make the output more interesting. Instead of using a set of parallel lines as a seed, the way I was doing with seed_rows(), I’ll use a set of lines with random lengths and orientations as the seed using the seed_sticks() function:

tempest(
seed = seed_sticks(n = 10),
iterations = 2,
line_width = 1
)

Depending on how the sticks fall, you can get some surprisingly evocative images with the code above. I had a lot of fun just running that code over and over to see what happens! There is one irritating limitation to this code, however: every image must include the straight lines that made up the original seed. Aesthetically I don’t find that at all unpleasant, to be honest, but sometimes you might want to create images that have more of a “ribbony” look to them. To do that, you can set a “burn in” period. By default the tempest() function sets burnin = 0 meaning that every iteration of the curl noise operation gets drawn, but if this is increased then it will only draw segments for later iterations, after the burn in period expires. For example, in this code we run the curl noise operation three times but only plot the last one:

tempest(
seed = seed_sticks(n = 10),
iterations = 3,
burnin = 2,
line_width = 1
)

You can play around with the seed type to get interesting variations. For example, the seed_bubbles() function generates a random set of circles that you can use as the seed, and when combined with a modest burnin value the result kind of looks like floating smoke rings:

tempest(
seed = seed_bubbles(n = 3),
iterations = 5,
burnin = 4,
line_width = 1
)

I really like this look, but I’m starting to get tired of seeing the viridis colour scheme over and over again. To allow some flexibility here, the tempest() function includes a palette argument that takes a palette-generating function (or a list of such functions) as its value. I wrote it that way so that tempest() can repeatedly call the palette function as it iterates, modifying the parameters (in particular the transparency) as it goes.

In any case, the way I used it here is to write a simple “function factory” called make_palette() that allows you to specify one of the scico palettes for the image. In the example below I used the “bilbao” palette:

make_palette <- function(name) {
function(n, alpha, ...) scico::scico(n, alpha, palette = name)
}

tempest(
seed = seed_bubbles(n = 3),
iterations = 5,
burnin = 4,
line_width = 1,
palette = make_palette("bilbao")
)

After playing around with this for a while I started to get curious about other mechanisms for displaying the seed besides the seed_col argument. Another variation I introduced was the seed_fill argument, which converts the seed elements to polygons and fills them. As a simple example, here’s a version with three circles used as the seed:

tempest(
seed = seed_bubbles(n = 3),
seed_fill = "black",
iterations = 10,
line_width = 1,
palette = make_palette("bilbao")
)

This “occlusion” effect is kind of neat, so I played around with it using a single bubble as the seed, running the algorithm for 2000 iterations and setting the alpha_decay parameter so that the intensity of the colour fades away gradually. The resulting image feels to me like a kind of “eclipse”:

tempest(
seed = seed_bubbles(n = 1),
seed_fill = "black",
iterations = 2000,
alpha_decay = .0025,
burnin = 500,
scale = 0.0075,
line_width = 1,
palette = make_palette("lajolla")
)

One of the things I love most about the idea of taking up generative art as a hobby, though, is the opportunities for unexpected delight. When I wrote the tempest() function I didn’t really have any clear goal in mind. I just wanted to explore. Sometimes I added function arguments because I was trying to understand what I’d just created. Other times I added them because there was a specific effect I was trying to produce (not always successfully). The “final” system is itself the result of an iterative, quasi-random walk over space of possible generative art functions. I’m a part of that stochastic system in a curious way. Often I’d see a surprising output and then be prompted to tweak the function this way and not that way. If I’d seen a different output, maybe I’d have followed a different trajectory and the function could have looked quite different.

Even so, tempest() still surprises me. I’ve explored only a small part of its functionality, and I don’t have very good intuitions about the output when I feed it different parameters. My favourite example of that is this code snippet, the output of which came as an utter surprise to me…

tempest(
seed = seed_bubbles(n = 3, grain = 100),
seed_fill = "#ffffff33",
iterations = 500,
alpha_init = 1,
alpha_decay = .0015,
burnin = 300,
scale = 0.005,
line_width = 1,
palette = make_palette("berlin")
)

I think this is truly gorgeous, but it’s nothing like what I had in mind when I started the project. It just sort of happened, and I’m utterly delighted.