Draw on the canvs with left mousebutton, erase with the center button, reset the canvas with ESC.
A fork of Zeichenwerkzeug by Michael Hengl
xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
}
function draw() {
//background(255,255,240,5);
//ellipse(mouseX, mouseY, 80, 80);
fill(255,255,255);
noStroke();
//checkt ob linke oder mittlere Maustaste gedrückt ist
if(mouseIsPressed){
if(mouseButton == LEFT){
if(mouseX < windowWidth/2){
fill(100+random(150),0,random(255));
rect(mouseX,mouseY,100,100);
}
else{
fill(0, random(150), random(199));
ellipse(mouseX,mouseY, 100,100);
}
}
if(mouseButton == CENTER){
fill(100);
ellipse(mouseX, mouseY, 150,150);//radieren
}
}
//beim drücken von escape-taste reset die Zeichenfläche.
if(keyIsPressed == true && keyCode == ESCAPE){
background(100);
}
}