Decisions if and co
in
Programming Questions
•
9 months ago
Hi ,
I'm trying to learning processing with the help of ''getting started with processing''
there were an example in the book , if the cursor of a mouse was on a circle, its make the size increase
and if not, the color change.
I've tried in vain to experiment with this, to do the same thing but if the cursor was out of the circle, i would make it decrease
until its original size. here the code if someone can help me.
int x=200;
int y= 200;
int radius =12;
void setup(){
noStroke();
size(400,400);
smooth();
ellipseMode(RADIUS);
}
void draw(){
smooth();
float d = dist(mouseX,mouseY,x,y);
if(d<radius){
radius++;
fill(0);}
else{
fill(255);
}
ellipse(x,y,radius,radius);
}
I'm trying to learning processing with the help of ''getting started with processing''
there were an example in the book , if the cursor of a mouse was on a circle, its make the size increase
and if not, the color change.
I've tried in vain to experiment with this, to do the same thing but if the cursor was out of the circle, i would make it decrease
until its original size. here the code if someone can help me.
int x=200;
int y= 200;
int radius =12;
void setup(){
noStroke();
size(400,400);
smooth();
ellipseMode(RADIUS);
}
void draw(){
smooth();
float d = dist(mouseX,mouseY,x,y);
if(d<radius){
radius++;
fill(0);}
else{
fill(255);
}
ellipse(x,y,radius,radius);
}
1