//load external library. import interfascia.*; //load accessory files. PImage grid; PImage clear; PFont lane; //define non-local variables. //load draw tool. boolean animation = false; //load pen attributes. int penColor; float penWeight; //= 5; //load color chooser. color currentPick; //load color randomizer (r-g-b). float modeAr; float modeAg; float modeAb; //load slo-mode speed trap. float speed = 30; boolean click = true; boolean speedVar = false; //load mode buttons from interfascia library. GUIController c; IFButton b1, b2, b3, b4; IFLabel l; void setup() { size(600,450); if(animation == false) animation = true; //set initial defaults currentPick = color(219,88,0); penWeight = 5; modeAr = 219; modeAg = 88; modeAb = 0; //set frameRate(speed); //define mode buttons. c = new GUIController(this); b1 = new IFButton("a", 542,250, 40,20); b2 = new IFButton("b", 542,295, 40,20); b3 = new IFButton("c", 542,340, 40,20); b4 = new IFButton("d", 542,385, 40,20); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); c.add(b1); c.add(b2); c.add(b3); c.add(b4); //eyedropper-ish palette. stroke(1); noFill(); rect(0,375, 75,75); } void draw() { //define left-hand menu. //color selectors. stroke(0); strokeWeight(1); fill(1); //if I use "0", it picks up the last selected color. Maybe a quirk? //ALT: fill(random(255),random(255),random(255)); rect(0,0, 75,75); fill(76); rect(0,75, 75,75); fill(153); rect(0,150, 75,75); fill(255); rect(0,225, 75,75); fill(modeAr, modeAg, modeAb); //random colorpicker; controlled by "a" button. rect(0,300, 75,75); noStroke(); //define right-hand menu. stroke(1); fill(255); rect(width-76,0, 75,224); rect(width-76,224, 75,225); lane = loadFont("LaneNarrow48.vlw"); fill(0); textFont(lane); textSize(17); text("s t r o k e", 534,215); text("m o d e", 537,440); //determined by controllers. stroke(penColor); //stroke properties toolbar. smooth(); stroke(1); strokeWeight(5); noFill(); ellipse(560,40, 10,15); strokeWeight(5); rect(555,78, 10,15); fill(0); strokeWeight(6); ellipse(560,130, 8,8); noStroke(); rect(554,165, 12,12); //stroke weight adjuster. if (mouseY <= 325) { if (mouseY < 0) { mouseY = 500; } float pctY = float(mouseY) / float(width); float lerpedY = lerp( 1, 30, pctY ); strokeWeight (lerpedY); } //strokeWeight(penWeight); stroke(penColor); //draw control if (mousePressed) line(mouseX,mouseY,pmouseX,pmouseY); } void mousePressed() //palette selection clicker. { //left-hand selective tool. //color picker. if(mouseX < 75) { if (get(mouseX,mouseY) != color(0)) { penColor = get(mouseX,mouseY); stroke(penColor); } } //right-hand selective tool. //stroke properties. if(mouseX > 550 && mouseX < 580 && mouseY >35 && mouseY < 60) { strokeJoin(ROUND); } if(mouseX > 550 && mouseX < 580 && mouseY >75 && mouseY < 95) { strokeJoin(SQUARE); } if(mouseX > 555 && mouseX < 565 && mouseY >125 && mouseY < 140) { strokeCap(ROUND); } if(mouseX > 555 && mouseX < 565 && mouseY >160 && mouseY < 175) { strokeCap(PROJECT); } //enter/exit slo-mode if click in (or too close to) button "c" if(mouseX > 542 && mouseX < 582 && mouseY > 3 && mouseY < 350) { click = !click; speedVar = true; } if(click == true) { frameRate(30); redraw(); } else { if(speedVar == true) { speed = 2; speedVar = false; } frameRate(speed); } } void actionPerformed (GUIEvent e) //interfascia buttons. b1=mode "a"; b2=mode "b", et alia. { if (e.getSource() == b1) //change available color { modeAr = random(255); modeAg = random(255); modeAb = random(255); frameRate(60); } else if (e.getSource() == b2) //clear background with randomized color. { noStroke(); fill(random(255),random(255),random(255)); rect(75,0, 450,500); frameRate(60); } else if (e.getSource() == b3) //dummy button for speed trap. { } else if (e.getSource() == b4) //dummy button to mess with user. { } }