//Generative project - Time //By Aylin Selcukoglu //Monday, April 5, 2004 //global variables Rectangle test; Rectangle[][] grid; int s; int sbefore = -1; int choice = -1; float rand; float rand2; float rand3; float randx; float randy; //sets up stage void setup() { size(400, 500); background(120); //text - time (vertical) fill(200); BFont myfont; myfont = loadFont("Bodoni.vlw.gz"); textFont(myfont, 50); text("t", 5, 20); text("i", 5, 50); text("m", 0, 70); text("e", 5, 90); //text - time definition fill(200); myfont = loadFont("OCR-A.vlw.gz"); textFont(myfont, 14); text("time (n.)", 40, 20); text("A nonspatial continuum in which events occur", 40, 40); text("in apparently irreversible succession from", 40, 50); text("the past through the present to the future.", 40, 60); //border fill(250); stroke(160); line(0, 95, 400, 95); //buttons rect(50, 90, 10, 10); rect(75, 90, 10, 10); rect(100, 90, 10, 10); //sine curve on top of line float a = 0.0; float inc = TWO_PI/25.0; for(int i=110; i<400; i=i+4) { line(i, 95, i, 95+sin(a)*10); a = a + inc; } setSquare(); } void loop() { //first choice - normal time (seconds) if(mousePressed && mouseX <= 60 && mouseX >= 50 && mouseY <= 100 && mouseY >= 90) choice = 1; //second choice - runs as fast as loop/program else if(mousePressed && mouseX <= 85 && mouseX >= 75 && mouseY <= 100 && mouseY >= 90) choice = 2; //third choice - follows mouse input (coordinates) else if(mousePressed && mouseX <= 110 && mouseX >= 100 && mouseY <= 100 && mouseY >= 90) choice = 3; if(choice == 1){ clearBackgrnd(); //top text fill(200); BFont myfont; myfont = loadFont("OCR-A.vlw.gz"); textFont(myfont, 14); text("every second goes by...", 40, 20); text("how much? how little? when? will time end?", 40, 40); text("will my thoughts and feelings", 40, 50); text("extend the bounds of time?", 40, 60); text("or will the colors fade to black?", 40, 70); setSquare(); slowTime(choice); } if(choice == 2){ clearBackgrnd(); //top text fill(200); BFont myfont; myfont = loadFont("OCR-A.vlw.gz"); textFont(myfont, 14); text("is this time?", 40, 20); text("unstructured...chaotic...", 40, 40); text("or is there structure in the chaos we see?", 40, 50); text("why does time feel as if it's accelerating", 40, 60); text("only to come to a crashing halt? leaving me", 40, 70); text("with nothing left? no time...", 40, 80); slowTime(choice); } if(choice == 3){ clearBackgrnd(); //top text fill(200); BFont myfont; myfont = loadFont("OCR-A.vlw.gz"); textFont(myfont, 14); text("you try to control time", 40, 20); text("but it's all in your head", 40, 40); text("time is an unharnessable creature...", 40, 50); text("control the paths you make", 40, 60); text("leave trails of color behind", 40, 70); text("and don't forget to spring forward", 40, 80); myTime(); } } //rectangle to cover text void clearBackgrnd(){ fill(120); noStroke(); rect(40, 10, sq(20), 75); } //first and second visualization void slowTime(int choice) { s = second(); if(s != sbefore){ //random numbers generated for fill color rand = random(500); rand2 = random(500); rand3 = random(500); //random x and y coordinates for specific rectangle randx = random(9); randy = random(9); //so when first visualization runs - with seconds //white can never be a fill color while(choice == 1 && rand == 250 && rand2 == 250 && rand3 == 250){ //random numbers generated for fill color rand = random(500); rand2 = random(500); rand3 = random(500); } } grid[int(randx)][int(randy)].changeFill(rand, rand2, rand3); if(choice == 1) sbefore = s; else if(choice == 2) sbefore = -1; } //third visualization - mouse input (coordinates) void myTime(){ s = second(); if(s != sbefore){ //random numbers generated for fill color rand = random(500); rand2 = random(500); rand3 = random(500); } for(int i = 0; i < 9; i++) for(int j = 0; j < 9; j++){ if(mouseX >= grid[i][j].xcoord && mouseX <= grid[i][j].xcoord + 20 && mouseY >= grid[i][j].ycoord && mouseY <= grid[i][j].ycoord + 20) grid[i][j].changeFill(rand, rand2, rand3); } sbefore = s; } void setSquare(){ grid = new Rectangle[9][9]; int xcoord = 30; int ycoord = 130; //initializes array of Rectangles for(int i = 0; i < 9; i++){ for(int j = 0; j < 9; j++){ grid[i][j] = new Rectangle(xcoord, ycoord, 20, 20); xcoord+=40; } xcoord = 30; ycoord+=40; } } //Rectangle Class public class Rectangle { public int xcoord; public int ycoord; public int recwidth; public int recheight; //constructor Rectangle(int xcoord, int ycoord, int recwidth, int recheight){ fill(250); stroke(160); this.xcoord = xcoord; this.ycoord = ycoord; this.recwidth = recwidth; this.recheight = recheight; rect(this.xcoord, this.ycoord, this.recwidth, this.recheight); } //changes fill color of rectangle public void changeFill(float value, float value2, float value3){ fill(value, value2, value3); stroke(160); rect(this.xcoord, this.ycoord, recwidth, recheight); } }