🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #155

Re: Clicking on Irregular Shapes

#155
From: Peter Schachte
Date: Fri, 23 Jun 1989 22:49
27 lines
1752 bytes
If you have enough memory to give each state/country/region/whatever a
different pixel value, the simplest, fastest way to do what you want is
to just check the pixel value of the pixel that was clicked on.  This
will tell you which state/country/region/whatever was selected.

A simple variation on this idea is to divide up your picture into a few
rectangular areas in each of which each color only appears in a single
state/country/region/whatever.  Then you can determine the
state/country/region/whatever from the area and color.  For example, you
might divide up a map of the US into 16 equal-sized parts so that each
part contains only one state with each of your, say, 8 pixel values.
I'm not sure if this is possible with a US map, but I'm sure you could
do it with 16 pixel values.  Anyway, you take the top 2 bits of the X
and Y component of the position selected, plus the 3 (or 4) bits of
pixel value for the selected pixel, and use that as an index into a
table of state names/numbers/whatever.

The beauty of the first approach, when it works, is that you can do
color table hacking to highlight the selected state.  Fast!

Hey, it may not be useful all that often but it sure is fast and easy
when it works!

-- 
-Peter Schachte
pds@quintus.uucp
...!sun!quintus!pds
Technical Details
Message-ID: <1201@quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!sun!quintus!pds
References: <42700015@m.cs.uiuc.edu> <7110@cbmvax.UUCP> <7007@ardent.UUCP> <12341@well.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!sun!quintus!pds
From: pds@quintus.UUCP (Peter Schachte)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Clicking on Irregular Shapes
Message-ID: <1201@quintus.UUCP>
Date: 23 Jun 89 22:49:54 GMT
References: <42700015@m.cs.uiuc.edu> <7110@cbmvax.UUCP> <7007@ardent.UUCP> <12341@well.UUCP>
Reply-To: pds@quintus.UUCP (Peter Schachte)
Organization: Quintus Computer Systems, Inc.
Lines: 27