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 › multiple reactive spots changing vars
Page Index Toggle Pages: 1
multiple reactive spots changing vars (Read 493 times)
multiple reactive spots changing vars
Nov 12th, 2007, 4:59pm
 
Hello all!

I'm on a project based on reacTIVision and I'm in the testing/prototyping phase.

For testing purposes,
I need to have multiple areas that change variables values if the mouse is over them.
Basically it would be like 4 ellipse that would respectively change the :
-x width
-y height
-size (both x and y)
-or color

of a rect (a fifth form in the sketch).

If the mouse is pressed and moved on one of these 4 ellipses then the corresponding variables will change.

I want to play with reacTIVision afterwards, and build a kind of chain that will display polygons, rectangles, lines, and ellipses, and change parameters of these forms whenever you add a module to the chain.

I don't really know how to get started.

I added a link to an image that explains what I want to do: http://www.amorphik.com/mid/TUI/


The classic sentence : "any help would be much appreciated"
Re: multiple reactive spots changing vars
Reply #1 - Nov 13th, 2007, 7:26am
 
Quote:
I don't really know how to get started.


Drawing the ellipses and test if the mouse is dragged over them would be a good start. You can use mouseDragged() method :

see http://processing.org/reference/mouseDragged_.html
Re: multiple reactive spots changing vars
Reply #2 - Nov 14th, 2007, 10:46am
 
Thank you for the reply!

Yes it would be a good thing to do. In fact, I was wondering how do we test if the mouse is inside an ellipse()?
It's simple to test if the mouse is inside a rect() because you test if the mouseX and mouse Y are inside a certain range, but what about the ellipse()? It seems to be more complicated due to the circular nature of the ellipse(). I need a kind of variable that will tell if I'm inside the circle or not.

Anyway, I will test the behavior of this chain thing with rect(); that's easier.

Now, the second question is : what is the smarter (and best) way to transmit variables from every rect() to the final rect(), which is the result of the four other rects?

I have posted the image explaining what I want to do on my server, if you want have a look.
Re: multiple reactive spots changing vars
Reply #3 - Nov 14th, 2007, 7:31pm
 
Just to answer quickly your first question :

Quote:
In fact, I was wondering how do we test if the mouse is inside an ellipse()?


If your ellipse is a perfect circle, it's easy : it has a center (x, y) and a radius (r). If the distance between your mouse and the center is lower than the radius, the cursor is inside.

Code:
boolean isInsideCircle(float x, float y, float r) {
float dx = mouseX - x;
float dy = mouseY - y;
float squareDistance = pow(dx, 2) + pow(dy, 2);
return(squareDistance < pow(r, 2));
}
Re: multiple reactive spots changing vars
Reply #4 - Nov 15th, 2007, 6:00am
 
Quote:
What is the smarter (and best) way to transmit variables from every rect() to the final rect(), which is the result of the four other rects?


You could think of each ellipse as a 'knob' - like a ControlP5 knob, see : http://www.sojamo.de/iv/pr/controlP5/applet/index.html

Then, your final rectangle would just have to get each knob's value before being displayed.
Page Index Toggle Pages: 1