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 › OnRollover in Processing
Page Index Toggle Pages: 1
OnRollover in Processing? (Read 401 times)
OnRollover in Processing?
Nov 3rd, 2008, 1:52pm
 
Hi Everyone.

I am currently in the process of attempting to make an interactive map using processing. However I am having difficulty finding a way to do a rollover on complex shape such as an imported svg of a country.

What I would like to be able to do is set a rollover specifically on the one complex (svg) shape that is drawn. Is that possible?
Re: OnRollover in Processing?
Reply #1 - Nov 3rd, 2008, 2:30pm
 
Maybe this hack could help you:

http://processing.org/hacks/doku.php?id=hacks:using-awt-s-polygon-class-to-test-for-insideness
Re: OnRollover in Processing?
Reply #2 - Nov 3rd, 2008, 2:54pm
 
i recomend colorbuffer picking.

http://processing.org/hacks/doku.php?id=hacks:picking_color_buffer

see createGraphics() in the reference.

F
Re: OnRollover in Processing?
Reply #3 - Nov 4th, 2008, 1:35pm
 
I made this using an image that was in data folder but was never displayed.
It works fine.
it can be seen at:
www.kubrusly.com/vicente/genius/
(click in the applet then any key starts or restarts the game)

The part of the code that uses this is;

PImage mapa; //<- never called for display.

//folowing is a method inside de sketch

int jog(){
 color cor= color(255);
 cor = mapa.get(mouseX,mouseY);  // mapa is a gray scale version of buttons
 int cori = int( cor >> 16 & 0xFF);   //<- bitwise "get red"

 switch (cori){
 case 30 :
   return 1;  
 case 70 :
   return 2;
 case 110 :
   return 3;
 case 150 :
   return 4;                
 default :
   return 8;
 }
}

The 2 images can be seen at :
www.kubrusly.com/vicente/genius/image_map.html



Re: OnRollover in Processing?
Reply #4 - Nov 4th, 2008, 1:54pm
 
Thank you all.

Unfortunately, these solutions are a bit beyond my level of understanding. I am going to have to learn a bit more before I attempt to implement one of these hacks.

Maybe something that can may be implemented in future releases of processing?
Re: OnRollover in Processing?
Reply #5 - Nov 4th, 2008, 3:55pm
 
devlar
I'm not a very experienced user, but i think that you want may be done in a simple way:
get your map in an image application.
make each region (countries or whatever) one single different color( i used different grays) the map and the graymouseovermap must be coincident.
define both as PImages.
load the map to display
test mouse position in graymouseovermap to see witch color is under the pointer.
That's it
I made this fast example for you. Note that mine gray map is not good (jpeg created different grays than i want) but is just a quick for instance.
The number at the bottom is the brightness value of under mouse region.
You can be much more precise, again it's a quick&dirt for instance.
I hope it helps
www.kubrusly.com/vicente/mapa/

the images used are at:
www.kubrusly.com/vicente/mapa/mapas.htm
Re: OnRollover in Processing?
Reply #6 - Nov 4th, 2008, 4:02pm
 
Thanks vicente!

That one actually did make sense. Dare I say this might actually be possible. I'll give it a try.
Page Index Toggle Pages: 1