// RAINMAKER // Aleksandr Prusakov und Robin Budel, ETH, CAAD Endwurf, Fall 2006 // --------------------------------------------------------------------------- // Scrollbars spacing constants int scrollLo = 540+25; // offset from main screen on left int scrollWs = 165; // text spacing int scrollHs = 30; // text height spacing int scrollW = 70; // scrollbar width int scrollH = 10; // scrollbar height int scrollS = 10; // scrollbar handle size int scrollWo = 40; // scrollbar width offset int scrollHo = 4; // scrollbar height offset // BRUSH CONTROL SCROLLBARS // scrollbar 1 - brush color int s1x = scrollLo+scrollWo; int s1y = 180+scrollHs-scrollHo; float s1p = 0.5; // scrollbar 2 - brush radius int s2x = 540+scrollWs+scrollWo; int s2y = 180+scrollHs-scrollHo; float s2p = 0.5; // scrollbar 3 - brush falloff int s3x = scrollLo+scrollWo; int s3y = 180+(scrollHs*2)-scrollHo; float s3p = 0.5; // scrollbar 4 - friction value int s4x = 540+scrollWs+scrollWo; int s4y = 180+(scrollHs*2)-scrollHo; float s4p = 0.5; // WATER CONTROL SCROLLBARS // scrollbar 5 - water speed int s5x = scrollLo+scrollWo; int s5y = 180+(scrollHs*5)-scrollHo; float s5p = 0.25; // scrollbar 6 - water flow int s6x = 540+scrollWs+scrollWo; int s6y = 180+(scrollHs*5)-scrollHo; float s6p = 0.5; // play/pause oscillator boolean play = false; int play2 = 0; Scroll s1, s2, s3, s4, s5, s6; // scrollbar initiation Play p; // play pause initiation // --------------------------------------------------------------------------- // Brush variables int brushS = int(100*s1p); // brush size float brushS2 = brushS/2; float brushX = 0; float brushB = s2p*100; // brush brightness float brushF = 100; // brush falloff float brushC = 100; // brush color // --------------------------------------------------------------------------- // WaterParticle variables //float acc; // acceleration of gravity in m/s^2, this is a constant float fW; // friction from Wall //float fricWall = -1.6; // factor of friction from wall //float speed = inSpeed; /////////////// // PARTICLES // /////////////// int particleNum = 2500; Particle[] water = new Particle[particleNum]; int sSize = 390; // size of screen int[] sVx = new int[int(pow(sSize,2))]; // screen x vector array int[] sVy = new int[int(pow(sSize,2))]; // screen y vector array int[] sS = new int[int(pow(sSize,2))]; // screen saturation array // int[] sVx = new int[10]; // screen x vector array // int[] sVy = new int[10]; // screen y vector array // --------------------------------------------------------------------------- PFont myFont; void setup() { // println("sVx = "); // println(sVx); println(pow(sSize,2)); println("begin"); size(880,600); colorMode(HSB,100,100,100); background(100,0,100); loadPixels(); // GUI SETUP // Text fill(66,50,50); PFont fontA = loadFont("ArialMT-48.vlw"); PFont fontAb = loadFont("Arial-BoldMT-48.vlw"); PFont fontA12 = loadFont("ArialMT-12.vlw"); // TITLES // scrollbars stroke(0,0,75); fill(0,0,95); s1 = new Scroll(s1x,s1y,scrollW,scrollH,16); s2 = new Scroll(s2x,s2y,scrollW,scrollH,16); s3 = new Scroll(s3x,s3y,scrollW,scrollH,16); s4 = new Scroll(s4x,s4y,scrollW,scrollH,16); s5 = new Scroll(s5x,s5y,scrollW,scrollH,16); s6 = new Scroll(s6x,s6y,scrollW,scrollH,16); rect(100,100,400,400); // screen fill(0,0,100); rect(101,101,398,398); loadPixels(); // PLAY, PAUSE, AND SAVE BUTTONS int butPauseX = scrollLo+1; // pause button int butPauseY = 120; int butPauseS = 30; // button size noFill(); rect(butPauseX,butPauseY,butPauseS,butPauseS); fill(0,0,90); rect(butPauseX+6,butPauseY+6,6,18); rect(butPauseX+18,butPauseY+6,6,18); int butPlayX = butPauseX+40; // pause button int butPlayY = butPauseY; noFill(); rect(butPlayX,butPlayY,butPauseS,butPauseS); fill(0,0,90); triangle(butPlayX+8,butPlayY+6,butPlayX+8,butPlayY+24,butPlayX+24,butPlayY+15); /* int butSaveX = butPauseX+80; // save buttom int butSaveY = butPauseY; noFill(); rect(butSaveX,butSaveY,butPauseS,butPauseS); fill(0,0,90); textFont(fontAb,30); text("S",butSaveX+6,butSaveY+27); */ // play pause p = new Play(butPlayX,butPlayY,butPauseX,butPauseY,butPauseS); // WATERPARTICLES for(int i=0; i < particleNum; i++) { water[i] = new Particle(random(110,490), random(108,490), fW); } fill(0,0,75); textFont(fontAb,24); text("RAINMAKER",100,50); textFont(fontA12,12); text("Press 's' to save drawing",100,580); textFont(fontA12,12); text("START/STOP",scrollLo,112); // BRUSH CONTROLS text("BRUSH",scrollLo,180); text("color",scrollLo,180+scrollHs); text("radius",540+scrollWs,180+scrollHs); text("falloff",scrollLo,180+(scrollHs*2)); text("friction",540+scrollWs,180+(scrollHs*2)); // WATER CONTROLS text("WATER",scrollLo+1,180+(scrollHs*4)); text("speed",scrollLo,180+(scrollHs*5)); text("depth",540+scrollWs,180+(scrollHs*5)); } void draw() { p.update(); p.draw(); // PAUSE FUNCTIONS if (play==false) { stroke(0,0,100); fill(0,0,100); rect(99,75,-50,448); rect(75,99,448,-50); rect(75,501,448,50); rect(501,75,50,488); noFill(); stroke(0,0,80); rect(scrollLo-7,164,270,90); noFill(); stroke(0,0,100); rect(scrollLo-7,180+(scrollHs*4)-16,270,60); s1.update(); s1.draw(); s2.update(); s2.draw(); s3.update(); s3.draw(); s4.update(); s4.draw(); // Brush brushS = int(200*s2p); // updates brush radius brushS2 = brushS/2; fill(0,0,100); if (mousePressed == true) { if (mouseX > 100 && mouseX < 500 && mouseY > 100 && mouseY < 500) { loadPixels(); brushX = mouseX-(brushS2); for(int i=0; i