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 › dynamic translation and mouse over boolean
Page Index Toggle Pages: 1
dynamic translation and mouse over boolean (Read 786 times)
dynamic translation and mouse over boolean
Nov 8th, 2006, 9:13pm
 
Hi,

I know how I make a group of elements on the screen and only interact with one of them at a time when the mouse is over each individual member of the group, but:

when I translate the position of the entire group of elements, I can't figure out where to update the new position of the elements in my code - i.e. if I make a grid of red squares and let them change into blue when I mouse over them, they will still change into blue, but they will not change into blue on the new position (200,200), but only in the old position (0,0)

How do I write a code where the mouseover boolean of individual members is updated with the translation of the group of members?

Thanks,
am

Re: dynamic translation and mouse over boolean
Reply #1 - Nov 8th, 2006, 9:22pm
 
Do you know about pushMatrix() & popMatrix() ?
Re: dynamic translation and mouse over boolean
Reply #2 - Nov 8th, 2006, 11:44pm
 
Yes, I do know about that. The problem is that the mouse effects the local this.ty, this.tx, but if the whole group is translated, then the this.tx and this.ty are moved ...
Re: dynamic translation and mouse over boolean
Reply #3 - Nov 9th, 2006, 11:02am
 
There's methods called screenX and screenY which will translate from the object's co-ordnates to where they actually appear on screen.

Sobefore any translate, screenX(100,100,0); will give 100, after a translate(20,0,0); it will give 120, since now 100,100 is actually on screen at 120,100.

So to do your picking and highlighting, you test mouse position vs screenX/y of the object, then if it's the chosen one, that screenX/Y gives you the centre to draw the highlighted version.
Page Index Toggle Pages: 1