🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Clicking on Irregular Shapes

#242
From: Peter Schachte
Date: Wed, 28 Jun 1989 21:51
30 lines
1902 bytes
In article <6124@microsoft.UUCP> bradch@microsoft.UUCP (Bradford Christian ms1) writes:
->In article <42700015@m.cs.uiuc.edu> schwager@m.cs.uiuc.edu writes:
->>Given an irregularly shaped object on a Screen, how can one tell if
->>the mouse button has been pressed inside of it?
->	Make each country a color different than it's neighbors using basic
->	topology rules.  ...  I repeat: this is a hack and will only
->	work under ideal conditions.  For example, if you label the countries,
->	the user would have to be careful not to click on the label (it would
->	be the wrong color).

There is a simple solution to that flaw:  allocate an extra plane for
the label, and set all pixel values with this bit on to the same label
color.  Then when you go to determine which country was clicked, get the
pixel value for that spot, and mask off that plane.  For example,
allocate 4 planes, and set pixel values 0-7 to nice, distinct colors,
and pixel values 8-15 to black (or whatever color you want labels in).
Then if you draw France in, say, color 3, draw the label "France" in color
11, which, anded with 7, gives you 3.

My earlier posting suggested a way to support more countries than you
have colors by dividing up your area into a grid, where each color only
appears once in each grid cell.

This may be a hack, but it's simplicity and efficiency make it a good
choice for many situations.

-- 
-Peter Schachte
pds@quintus.uucp
...!sun!quintus!pds
Technical Details
Message-ID: <1202@quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!sun!quintus!pds
References: <42700015@m.cs.uiuc.edu> <6124@microsoft.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!sun!quintus!pds
From: pds@quintus.UUCP (Peter Schachte)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Clicking on Irregular Shapes
Message-ID: <1202@quintus.UUCP>
Date: 28 Jun 89 21:51:28 GMT
References: <42700015@m.cs.uiuc.edu> <6124@microsoft.UUCP>
Reply-To: pds@quintus.UUCP (Peter Schachte)
Organization: Quintus Computer Systems, Inc.
Lines: 30