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 & HelpSyntax Questions › Triangle Rollover
Page Index Toggle Pages: 1
Triangle Rollover (Read 961 times)
Triangle Rollover
Nov 20th, 2009, 5:16am
 
Hey guys,

I was programming a bit, when suddlenly came on my mind a little problem. I was wondering about a way to detect a triangle rollover and when is detected that would change its color for example. After some research i still can't get it. Can you please help me?

Ty in advance,
Zoon
Re: Triangle Rollover
Reply #1 - Nov 20th, 2009, 6:01am
 
http://mathforum.org/library/drmath/view/54505.html
Re: Triangle Rollover
Reply #2 - Nov 22nd, 2009, 5:10pm
 
If you are not too worried about speed (added calls to methods), you can use Java's polygon class.
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Polygon.html
There is a method called contains(). Simply pass your coordinates and it returns true or false.
Re: Triangle Rollover
Reply #3 - Nov 22nd, 2009, 5:46pm
 
there is an example in the hacks section : http://processing.org/hacks/doku.php?id=hacks:using-awt-s-polygon-class-to-test-for-insideness
Page Index Toggle Pages: 1