We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › mouse proximity math
Page Index Toggle Pages: 1
mouse proximity math (Read 326 times)
mouse proximity math
Apr 1st, 2008, 3:17pm
 
I'm pretty new to programming so forgive my ignorance on what should be a fairly simple task.
I have 8 static elipses arranged in a circle.
I would like their brightness adjusted according to mouse proximity. I can't work out the maths for this.
have searched the site for answers but haven't found anything. Any help/pointers to examples greatly appreciated.

Thanks


 int a = 128;
 int b = 128;
 int c = 128;
 int d = 128;
 int e = 128;
 int f = 128;
 int g = 128;
 int h = 128;


void setup(){
 size(640, 640);
 smooth();
 background(0);
 noStroke();
}

void draw() {
 fill(a);
 ellipse(320,120, 64, 64);
 fill(b);
 ellipse(461,179, 64, 64);
 fill(c);
 ellipse(520,320, 64, 64);
 fill(d);
 ellipse(461,461, 64, 64);
 fill(e);
 ellipse(320,520, 64, 64);
 fill(f);
 ellipse(179,461, 64, 64);
 fill(g);
 ellipse(120,320, 64, 64);  
 fill(h);
 ellipse(179,179, 64, 64);  
}
Re: mouse proximity math
Reply #1 - Apr 1st, 2008, 4:15pm
 
Check out http://processing.org/reference/dist_.html that'll give you the distance between two points, e.g. the centre of an ellipse, and mouseX,mouseY
Page Index Toggle Pages: 1