20. September 2013
void setup() { size(500, 500); background(255); } float colR = 0; float colG = 0; float colB = 0; void draw() { noStroke(); if (mousePressed && (mouseButton == LEFT)) { strokeWeight(30); stroke(colR,colG,colB); line(mouseX, mouseY, pmouseX, pmouseY); } else if (mousePressed && (mouseButton == RIGHT)) { strokeWeight(30); stroke(255); line(mouseX, mouseY, pmouseX, pmouseY); } if (key == 'r' && keyPressed) { strokeWeight(30); stroke(random(0,255),random(0,255),random(0,255)); line(mouseX, mouseY, pmouseX, pmouseY); } if (key == 'l' && keyPressed) { stroke(random(0,255),random(0,255),random(0,255)); fill(random(0,255),random(0,255),random(0,255)); strokeWeight(random(1,5)); line(0,0, random(0,height),random(0,width)); } if (key == 'd' && keyPressed) { background(255); } } void keyPressed() { switch(key) { case '1': colR = 255; colG = 0; colB = 0; break; case '2': colR = 0; colG = 255; colB = 0; break; case '3': colR = 0; colG = 0; colB = 255; break; case '4': colR = (random(0,255)); colG = (random(0,255)); colB = (random(0,255)); break; } }