/*Project 2. Representational of Theo Van Doesburg's Composition IX, opus 18. Alan Schulte*/ //red button starts program running. /*Cascading rectangles to resemble image. Random coinciding black and white rectangles. Random grey rectangles. Mouse click creates random blue rectangles*/ //button variable used to start program boolean button = false; //button position and size variables int a = 0; int b = 0; int c = 50; int d = 20; //setup canvas with static black background, and white inner rect. void setup(){ size(500,500); background(0); frameRate(3); //setting framerate as 3 for a nice slow pace. //White inner square/canvas. rectMode(CENTER); noStroke(); fill(255); rect(width/2,height/2,width-20,height-20); } /*when mouse is pressed, a random blue rectangle will appear. Button press to start running the program also.*/ void mousePressed(){ //button press if(mouseX > a && mouseX < a+c && mouseY > b && mouseY < b+d ){ button = !button; } //random position and size variables for blue rectangles float x = random(50,450); float y = random(50,450); float w = random(5,25); float h = random(5,50); //Blue rectangles noStroke(); fill(0,0,255,170); rectMode(CENTER); rect(x,y,w,h); } void draw() { if (button){ /*Setting my variables for my black areas to be random for both position and size. These will remain throughout the full span of the piece.*/ float x = random(50,450); float y = random(40,425); float z = random(10,130); float w = random(10,130); float xx = random(40,430); float yy = random(60,430); float ww = 25; float hh = 55; //Random black rectangles, meant to represent those in piece. rectMode(CENTER); noStroke(); fill(0); rect(x,y,z,w); //Random white rectangles also. rectMode(CORNER); noStroke(); fill(255); rect(x,y,w,z); //cascading rectangles, loops wouldn't work as intended :'( rectMode(CENTER); strokeWeight(3); stroke(0); fill(255); rect(xx,yy,ww,hh); rect(xx,yy-5,ww,hh); rect(xx,yy-10,ww,hh); rect(xx,yy-15,ww,hh); rect(xx,yy-20,ww,hh); //grey rectangles noStroke(); fill(125); rect(random(30,470),random(30,470),random(5,15),random(5,15)); }else{ //rectangle clears to white with black back if button off. rectMode(CENTER); noStroke(); fill(0); rect(width/2,height/2,width,height); rectMode(CENTER); noStroke(); fill(255); rect(width/2,height/2,width-20,height-20); } //button noStroke(); fill(255,0,0,255); rect(a,b,c,d); }