Drawing quads with mouse (increase size automatically)
float x1,y1,x2,y2,x3,y3,x4,y4;
float centerX, centerY;
float quadSize;
void setup() {
size(400,400);
framerate(10);
smooth();
noStroke();
}
void draw() {
// CHANGE COLOR FROM WHITE TO BLACK WITH MOUSECLICK
if(mousePressed) {
fill(0,50);
}
else {
fill(255,50);
}
centerX = mouseX;
centerY = mouseY;
quadSize++;
x1 = centerX - random(quadSize);
y1 = centerY - random(quadSize);
x2 = centerX + random(quadSize);
y2 = centerY - random(quadSize);
x3 = centerX + random(quadSize);
y3 = centerY + random(quadSize);
x4 = centerX - random(quadSize);
y4 = centerY + random(quadSize);
// clear the screen if user press a key
if(keyPressed) background(200);
quad(x1,y1,x2,y2,x3,y3,x4,y4);
}
0 Comments:
Post a Comment
<< Home