Growing red transparent circle?
in
Programming Questions
•
1 year ago
I'm trying to get a growing red circle which is centered at the location where the mouse is pressed. The circle, as it grows, will become more transparent and eventually disappear when the diameter of the circle reaches 255.
I have also drawn a rectangle in the center of the sketch. It would be good if nothing happens when I click in side the rectangle..only when outside. This is what I have so far. Please help me!
float dia = 50;
void setup() {
size(400,300);
background(255);
stroke(0,255,0);
rectMode(CENTER);
rect(200,150,width/2,height/2);
strokeWeight(width/10);
noStroke();
stroke(0,0,255);
rect(200,150,10,110);
rect(200,150,160,10);
}
void draw() {
strokeWeight(2);
stroke(255,0,0);
if (mousePressed && (mouseButton == LEFT)) {
if( dist(mouseX, mouseY, width/2, height/2) >= 130 ) {
fill(255);
ellipse(mouseX, mouseY, dia, dia);
dia++;
if(dia >= 250)
dia--;
}
}
}
1