Generative art -Brenda

Generative art – change colour and primitives

/*
* Creative Coding
* Week 2, 05 – Moving Patterns 1
* by Indae Hwang and Jon McCormack
* Copyright (c) 2014 Monash University
*
* This sketch builds on the previous sketches, drawing shapes based on the
* current framerate. The movement of individual shapes combine to create a
* gestalt field of motion. Use the arrow keys on your keyboard to change the
* frame rate.
*
*/

 

//Amended by Brenda O’Neill on 19th August, 2015
int frame_rate_value;

void setup() {
size(500, 500);

// variable used to store the current frame rate value

frame_rate_value = 6;
frameRate(frame_rate_value);
rectMode(CENTER);
background(255);
}
void draw() {

background(#7ECFFA);//changed from white

int num = 15;//number of circles changed from 20 to 15
int margin = 0;
float gutter = 0; //distance between each cell
float cellsize = ( width – (2 * margin) – gutter * (num – 1) ) / (num – 1);

int circleNumber = 0; // counter
for (int i=0; i<num; i++) {
for (int j=0; j<num; j++) {
circleNumber = (i * num) + j; // different way to calculate the circle number from w2_04

float tx = margin + cellsize * i + gutter * i;
float ty = margin + cellsize * j + gutter * j;

movingCircle(tx, ty, cellsize, circleNumber);
}
}
} //end of draw
void movingCircle(float x, float y, float size, int circleNum) {

float finalAngle;
finalAngle = frameCount + circleNum;

//the rotating angle for each tempX and tempY postion is affected by frameRate and angle;
float tempX = x + (size / 2) * sin(PI / frame_rate_value * finalAngle);
float tempY = y + (size / 2) * cos(PI / frame_rate_value * finalAngle);

if(circleNum%2==0) //if, when divided by two it is an even number then…
{
noStroke();
//stroke(1);
//fill(0);
fill(#FA0324);//colour red
ellipse(tempX, tempY, size, size);//size/5 changed to size
fill(#0F6AF7);//colour blue
rect(tempX, tempY, 1, size*5);
stroke(0);
noFill();
stroke(2);
line(x, y, tempX, tempY);
}

else//not even number then…
{
noStroke();
fill(#0FF71C); //colour Green
rect(tempX, tempY, size/2, size/2);//size/5 changed to size/2
fill(#F30FF7);//colour pink
rect(tempX, tempY, 1, size*5);
stroke(0);
noFill();
stroke(0);
line(x, y, tempX, tempY);
}}

/*
* keyReleased function
*
* called automatically by Processing when a keyboard key is released
*/
void keyReleased() {

// right arrow — increase frame_rate_value
if (keyCode == RIGHT && frame_rate_value < 60) {
frame_rate_value++;
}

// left arrow — decrease frame_rate_value
if ( keyCode == LEFT && frame_rate_value > 1) {
frame_rate_value–;
}

// set the frameRate and print current value on the screen
frameRate(frame_rate_value);
println(“Current frame Rate is: ” + frame_rate_value);
}