 # Objective

Create an engaging 400x400 generative art poster designs based around the theme of Movement and energy.

# Inspiration

This project has been inspired by fractal systems created using recursive art by Matthew James Taylor. Recursive functions are powerful tool in computational science, and have the ability to create an infinite number of objects using small number of variables.

"The power of recursion evidently lies in the possibility of defining an infinite set of objects by a finite statement. In the same manner, an infinite number of computations can be described by a finite recursive program, even if this program contains no explicit repetitions." - Wirth, Niklaus (1976). Algorithms + Data Structures = Programs. Prentice-Hall. p. 126.

This project uses similar recursive structure to the Recursive Tree proccessing example by Daniel Shiffman, however draws shapes instead of branches to create a more engaging imagery, with energetic colours.

## Shapes

For each run the program selects a circle, a square or a triangle.The program starts by drawing the largest shape then splits to call the same recursive function with the element size reduced to 70% of the original.

## Colours

Added variation in hue colours to replace the mono colour of the drawn objects, the variation in color suggests energetic imagery as the illustration with the variation in color looks less dull than a single color pattern, colour variation is also related to the colour step variable incStep, larger incStep speed up the variation in colour between each step.

## Filters and for loops

Repeating the same object with a different color and size generated variaying pattern however the fact still remains that all objects follow same structer of the shape. I add a filter after the objects are drawn with random repeats to increase the uniqueness of each shape drawn, and the overall uniqueness of each generated poster.

## Background

The drawn objects look distinct from the background when the background is black or white, gray and other colors visually interfere with the generated pattern, while back and white keeps the drawing distinct from the background.

# Final code

• Show Sketch
``````/** @peep sketchcode */
int theta;   // angle of branch rotation
int shapeNumber;// 0 - draws rectangles, 1 - draws circles, 2 - triangles.
void setup() {
// using the setup function to initalise the start settings
colorMode(HSB, 255);// changing the colour mode to use hue saturation and brightness instead of rbg
size(400,400);// canvas size
noLoop();// prevents the draw function from looping
}
void draw(){
// sets the random values for shape, branch angle and background colour starts the recursive function
shapeNumber = round(random(2));// randomly selects the shape drawn
theta = round(random(90,270));// genrates a random angle for branching
background(round(random(1))*255);// randomly sets the background to black or white
translate(width/2,height/2);// moves the drawing of the matrix to the center
element(150);  // Start the recursive function with intial element size of 150
inc =0;// setting the starting hue staturation color to 0(red)
repeatFilter(round(random(3)));//applies a filter a random number of times
}
float spacing = random(0.5,0.9); //this variable is inversly propotional to the distance between elements
float inc = 0; // increment of color on HSB spectrum
float incStep = random(0.005,0.03);//colour step size, larger values have a higher variation in colors
void element(float e) {
inc+=incStep;// changes the colour at each recursion
color c = color(inc, 186, 255); //set c to colour with value inc and saturation 186 with full brightness(255)
noStroke(); //removes the objects outlines
fill(c); // fills the object with the incremented colour c
e*= 0.70;// reduce the element size
// the if statement is used to exist the recursive function when the size of the element is reduced to less than 1
if (e > 2) {
pushMatrix();// initating matrix repostioning
translate(0, -e/spacing); // Move to the next drawing position(changing the spacing variable changes the distance between the elements)
element(e);       // calling it self with a reduces e value and inside the new matrix
//checks what shape to draw, by looking at the shapeNumber variable
if (shapeNumber == 0){
// checks if shapeNumber is 0 it draws a rectangle
rect(random(1), random(1), e, -e);//draws a square using the the element size e, with a slightly randomly offset position

}
else if(shapeNumber == 1){
ellipse(random(1), random(1), e, -e);//draws a circle using the the element size e, with a slightly randomly offset position

}
else if(shapeNumber == 2){
triangle(0, 0, e/1.12,e/1.12,e/1.12, -e/1.12);// draws a triangle
}

popMatrix();// returning to the previous
pushMatrix();/*repostioning the Matrix without calling to the shape drawing
function, this reduces the number of items in half while keeping the branching pattern*/
translate(0, -e);
element(e);//calling the recursive function with the new 1inside the new matrix
popMatrix();//exists the modified matrix
}
}
// filter(DILATE,INT) didnt work for unknown reason, so the for loop repeats it manually
void repeatFilter(int repeats){
for(int i=0; i<repeats; i++){
filter(DILATE);// uses the dilate filter on the canvas
}
}
void mouseClicked(){
//saveFrame("DECO1012A1-######.png");//stores a png file of the genrated drawing
redraw();// repeats the draw function when mouse is clicked
}``````