Contact FutureLearn for Support
Skip main navigation
We use cookies to give you a better experience, if that’s ok you can close this message and carry on browsing. For more info read our cookies policy.
We use cookies to give you a better experience. Carry on browsing if you're happy with this, or read our cookies policy for more information.
Still frame from the w3_03 sketch
The w3_03 sketch

Where do rules come from?

If rule-based art is concerned with creating rules that generate a work, how do you devise rules that make interesting art?

This is an fascinating question, perhaps it is the question for this course. Some rules seem deceptively simple and it isn’t always clear where the interest they generate comes from.

One approach to developing your own rule-based systems is to start with something very simple and make small, incremental changes to it. At each change, observe the ‘generative complexity’ of what is produced. As you explore this space of possibilities you can pursue the interesting options while discarding those that are less so.

Earlier we discussed the sin() function and looked at a simple sketch with oscillating circles moving horizontally at different speeds (w3_02). We could use this sketch as a starting point to develop a rule-based generative art system.

After some brief experimentation, here’s what we came up with:

  • A series of oscillating points move horizontally across the screen. The points divide the screen evenly.
  • If a point and its next neighbour point are closer than some fixed distance, draw a line between the points.

If we want a computer to generate our art, we’ll need to convert these rules into computer code. To do this, we need to interpret our rules or ‘algorithm’ in a way that gives us an unambiguous set of instructions that can be executed by the computer.

We’ve already implemented the first part of our algorithm in the w3_02 sketch, we just need to change the circles to points, then implement the distance rule.

Open the w3_03 sketch. This version implements the rules as code. Run the sketch and observe the results. Some points to note:

  • The sketch makes use of the entire screen: size(displayWidth, displayHeight);. If you’d prefer working with a smaller display window comment out this line and uncomment size(500, 500); directly below.
  • Change the values of num and distanceMargin and observe the results. Make sure you understand what these two variables are doing.
  • If you want to see the moving points, uncomment the stroke(255); statement within the draw() function.
  • As with the other sketches this week, you can change the background colour using the mouse.
  • Note the use of many of the functions we’ve covered this week: sin(), cos(), radians(), dist() and map();

One final thing to be aware of: the draw() function does not call background() at all. What effect is this having on the drawing? Uncomment the line ‘background(128);’ and run the sketch.

Another way to devise rules is to start with some physical process using simplification and abstraction to devise a set of rules. We’ll look at this approach next.

Share this article:

This article is from the free online course:

Creative Coding

Monash University

Course highlights Get a taste of this course before you join: