int i=0; //boolean drawMode=false; boolean autoplay=false; float point_x=mouseX; float point_y=mouseY; float point_x_pre; float point_y_pre; float direction_x; float direction_y; float x=1; float y=1; float diameter; boolean drawMode = false; boolean autoDraw = false; boolean autoColor = false; boolean autoDiameter = false; boolean position0 = false; boolean position1 = false; boolean position2 = false; boolean button0Press = false; boolean button1Press = false; boolean button2Press = false; boolean sliderPosition1 = false; boolean sliderPosition2 = false; boolean sliderPress1 = false; boolean sliderPress2 = false; int bSize = 24; int bMargin = 12; int position0A = bMargin; int position0B = bMargin + bSize; int position0C = bMargin; int position0D = bMargin + bSize; int position1A = bMargin; int position1B = bMargin + bSize; int position1C = bMargin + (1 * bMargin) + (1 * bSize); int position1D = bMargin + (1 * bMargin) + (1 * bSize) + bSize; int position2A = bMargin; int position2B = bMargin + bSize; int position2C = bMargin + (2 * bMargin) + (2 * bSize); int position2D = bMargin + (2 * bMargin) + (2 * bSize) + bSize; int position1sA = (2 * bMargin) + bSize + bSize/20; int position1sB = (2 * bMargin) + bSize + bSize * 5 - bSize/10; int position1sC = (1 * bMargin) + 1 * bSize + 1 * bMargin; int position1sD = (1 * bMargin) + 1 * bSize + 1 * bMargin + bSize; int position2sA = (2 * bMargin) + bSize + bSize/20; int position2sB = (2 * bMargin) + bSize + bSize * 5 - bSize/10; int position2sC = (1 * bMargin) + 2 * bSize + 2 * bMargin; int position2sD = (1 * bMargin) + 2 * bSize + 2 * bMargin + bSize; int counter; int sliderX; int sliderY; int sliderWidth; int knobPosition1 = 2 * bMargin + bSize; int knobPosition2 = 2 * bMargin + bSize + 5 * bSize - bSize/5; int sliderStroke; int knobStroke; int xx= 0; int yy= 0; float wwidth= 0; float hheight= 0; float circlePositionX; float circlePositionY; float circleDiameter; float circleHue = 0; float sliderHue1; float sliderHue2; float multiplier; float sliderHeight; float sliderHeight2 = bSize; void setup(){ size(800, 500); //size(screen.width, screen.height); noStroke(); smooth(); frameRate(60); colorMode(HSB,100, 100,100,100); background (25); int circlePositionX = width/2; int circlePositionY = height/2; PFont metaBold; metaBold = loadFont("AquaBase-48.vlw"); textFont(metaBold, 14); textAlign(LEFT); sliderHue1=0; instructions(); } void draw(){ buttonLogic(); autoDrawMode(); drawMode(); clearScreen(); textBackground(); screenText(); button0(); if (button0Press==false){ if (button1Press){ button1(); } else { button1(); slider1(); } if (button2Press){ button2(); } else { button2(); slider2(); } } //println(autoColor); } void textBackground(){ if(autoDraw){ wwidth= bMargin *2 + bSize + 82; hheight= bMargin * 2 + bSize * 1; } else { if(autoColor==false || autoDiameter==false){ wwidth= bMargin *3 + bSize*6 + 82; hheight= bMargin * 4 + bSize * 3; } else { wwidth= bMargin *2 + bSize*1 + 110; hheight= bMargin * 4 + bSize * 3; } } fill (25); rectMode(CORNER); noStroke(); rect(xx,yy, wwidth, hheight); } void screenText(){ fill (0); textAlign(LEFT); if (autoDraw){ text("Auto Draw", bMargin *2 + bSize, bMargin + bSize*3/4); } else { text("Manual Draw", bMargin *2 + bSize, bMargin + bSize*3/4); if (autoColor){ text("Random Color", bMargin *2 + bSize, bMargin*2 + bSize + bSize*3/4); } else { text("Pick Color", bMargin *3 + bSize*6, bMargin*2 + bSize + bSize*3/4); } if (autoDiameter){ text("Random Circles", bMargin *2 + bSize, bMargin*3 + bSize*2 + bSize*3/4); } else { text("Pen Size", bMargin *3 + bSize*6, bMargin*3 + bSize*2 + bSize*3/4); } } } void buttonUp(int buttonUpInstance){ rectMode(CORNER); rect (bMargin, bMargin + buttonUpInstance*bSize + buttonUpInstance*bMargin, bSize, bSize); } void buttonDown(int buttonDownInstance){ rectMode(CORNER); stroke (50); strokeWeight(1); fill (0); rect (bMargin, bMargin + buttonDownInstance*bSize + buttonDownInstance*bMargin, bSize, bSize); line (bMargin+3, bMargin + buttonDownInstance*bSize + buttonDownInstance*bMargin+3, bMargin + bSize-3, bMargin + buttonDownInstance*bSize + buttonDownInstance*bMargin + bSize-3); line (bMargin + bSize-3, bMargin + buttonDownInstance*bSize + buttonDownInstance*bMargin+3, bMargin+3, bMargin + buttonDownInstance*bSize + buttonDownInstance*bMargin + bSize-3); } void sliderBox(int sliderInstance, float sliderHeightValue, float sliderHue, int sliderBrightness, int sliderSaturation){ rectMode(CENTER); stroke(sliderStroke); strokeWeight(1); fill(sliderHue, sliderBrightness, sliderSaturation, 100); sliderX = bMargin * 2 + bSize; sliderY = bMargin + sliderInstance * bSize + sliderInstance * bMargin; sliderWidth = bSize * 5; sliderHeight = sliderHeightValue; rect (sliderX+sliderWidth/2, sliderY+bSize/2, sliderWidth, sliderHeight); } void sliderKnob(int knobInstance, int knobPosition){ rectMode(CORNER); stroke (knobStroke); strokeWeight(1); fill (15); rect (knobPosition, sliderY, bSize / 5, bSize); } void slider1(){ sliderStroke=15; knobStroke=15; if(sliderPosition1 && mousePressed){ knobPosition1= mouseX - bSize / 10; sliderHue1=map(knobPosition1, position2sA, position2sB, 0, 100); } sliderBox(1, bSize, sliderHue1, 70, 80); sliderKnob(1, knobPosition1); } void slider2(){ sliderStroke=15; knobStroke=15; if(sliderPosition2 && mousePressed){ knobPosition2= mouseX - bSize / 10; sliderHeight2=map(knobPosition2, position2sA, position2sB, 1, bSize); } sliderBox(2, sliderHeight2, 0,0,50); sliderKnob(2, knobPosition2); } void button0(){ if (button0Press){ buttonDown(0); } else { if (position0){ strokeWeight(1); stroke (85); fill (65); buttonUp(0); } else { strokeWeight(1); stroke (35); fill (15); buttonUp(0); } } } void button1(){ if (button1Press){ buttonDown(1); } else { if (position1){ strokeWeight(1); stroke (85); fill (65); buttonUp(1); } else { strokeWeight(1); stroke (35); fill (15); buttonUp(1); } } } void button2(){ if (button2Press){ buttonDown(2); } else { if (position2){ strokeWeight(1); stroke (85); fill (65); buttonUp(2); } else { strokeWeight(1); stroke (35); fill (15); buttonUp(2); } } } void autoDrawMode(){ if (autoDraw){ drawMode(); } else { } } void drawMode(){ if(autoDiameter==false && autoDraw==false){ stroke(15); strokeWeight(1); fill (0,0,25,100); //set the fill color rect(bMargin*2 + bSize, bMargin*3 + bSize*2, bSize * 5, bSize); //draw a rectangle that covers the older circles } if(autoDraw){ point_x_pre=point_x; point_y_pre=point_y; i++; if(i>70){ //within 1~90, x & y 's direction int[] numbers = { -1,1 }; x=numbers[int(random(0,2))]; y=numbers[int(random(0,2))]; i=0; } if(point_x>width-20){ //if close to the frame x=random(-3, 0); } else if (point_x<20){ x=random(0,3); } if(point_y>height-20){ y=random(-2, 0); } else if (point_y<20){ y=random(0,2); } point_x=point_x+x*random(0,9); point_y=point_y+y*random(0,9); multiplier=dist(point_x,point_y,width/2,height/2)/(height/25); //set the diameter based on how close the mouse is to the center of the screen diameter=dist(point_x,point_y,point_x_pre,point_y_pre)*multiplier*2/3; //set the diameter based on how fast the mouse moves //fill (0,0,0,4); //set the fill color //rect(0,0,width,height); //draw a rectangle that covers the older circles noStroke(); fill(0,0,0,random(10,30)); //set the shadow color to be light or dark ellipse(point_x+5, point_y+5, diameter*1.1, diameter*1.1); //draw a shadow that is slightly bigger than the circle fill(random(0,100), random(50,75), random(90,100), 100); //pick a random bright color ellipse(point_x, point_y, diameter,diameter); //draw a colored circle } else { if(autoColor){ circleHue=random(0,100); } else { circleHue=sliderHue1; } if(drawMode){ if((abs(mouseX-pmouseX)>0) || (abs(mouseY-pmouseY)>0)){ if(autoDiameter){ multiplier=dist(mouseX,mouseY,width/2,height/2)/(height/15); circleDiameter= dist(mouseX,mouseY,pmouseX,pmouseY)*multiplier + 10; circlePositionX = mouseX; circlePositionY = mouseY; noStroke(); strokeWeight(1); fill(0,0,0,random(10,30)); ellipse(circlePositionX+5, circlePositionY+5, circleDiameter*1.1, circleDiameter*1.1); fill(circleHue, random(74,75), random(90,91), 100); ellipse(circlePositionX, circlePositionY, circleDiameter, circleDiameter); } else { strokeWeight(sliderHeight2*2.15); // stroke(0, 0, 0, random(10, 30)); line shadow // line(mouseX+5, mouseY+5, pmouseX+5, pmouseY+5); line shadow strokeWeight(sliderHeight2*2); stroke(circleHue, 75, 90, 100); line(mouseX, mouseY, pmouseX, pmouseY); } } } else { } } } void buttonLogic(){ if (mouseX > position0A && mouseX < position0B && mouseY > position0C && mouseY < position0D){ position0=true; } else { position0=false;} if (mouseX > position1A && mouseX < position1B && mouseY > position1C && mouseY < position1D){ position1=true; } else { position1=false;} if (mouseX > position2A && mouseX < position2B && mouseY > position2C && mouseY < position2D){ position2=true; } else { position2=false;} if (mouseX > position1sA && mouseX < position1sB && mouseY > position1sC && mouseY < position1sD){ sliderPosition1=true; } else { sliderPosition1=false;} if (mouseX > position2sA && mouseX < position2sB && mouseY > position2sC && mouseY < position2sD){ sliderPosition2=true; } else { sliderPosition2=false;} } void clearScreen(){ if (keyPressed){ noStroke(); rectMode(CORNER); fill(25); rect(0,0,width,height); instructions(); } } void instructions(){ fill(0); textAlign(CENTER); text("Press spacebar to clear screen. Click mouse to start/stop drawing.", width/2, height - bSize); } void mousePressed(){ if (position0){ autoDraw= !(autoDraw); button0Press= !(button0Press); } if (position1){ autoColor= !(autoColor); button1Press= !(button1Press); } if (position2){ autoDiameter= !(autoDiameter); button2Press= !(button2Press); } if (position0==false && position1==false && position2==false && sliderPosition1==false && sliderPosition2==false){ drawMode= !drawMode; } }