Path: 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 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