Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!wuarchive!m.cs.uiuc.edu!schwager From: schwager@m.cs.uiuc.edu (Michael Schwager) Newsgroups: comp.sys.amiga.programmer Subject: Re: Clicking on irregular shapes? Message-ID: <1991Mar28.234604.22793@m.cs.uiuc.edu> Date: 28 Mar 91 23:46:04 GMT References: <1991Mar27.212214.6204@orfeo.radig.de> Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL Lines: 40 eric@orfeo.radig.de (Eric Tuerlings) writes: >I can remember there was a discussion last year about: "Clicking on >irregualar shapes". Because I want to use irregular shapes to click on, >I am interested in a solution to this problem, since I found nothing else >than to click on rectangle shapes only. >Does somebody know a solution? >-- >Eric Tuerlings, E-Mail: eric@radig.de Hi, I was the one who asked the question. I'll try to describe what I did: I have a map of the world, that looks remarkably like a Risk board :-). I made it using DPaint. I saved each territory as a seperate brush. Then I used iff2c on each of those files, and got a lovely 1-bitplane description of the shape (if your shapes are >1 bitplanes deep, I suggest converting them to only a single color before saving them, so iff2c creates a single bitplane representation of the shape... a "cookie"). It was kind of a tedious process: first I cleaned up all around the image, then I used the grab brush tool (grabbing a rectangular area and noting the upper left coordinates of the object), then I saved this brush, and finally used iff2c on it. iff2c will give you the width and height of your object (in an Image structure). So now I have this file that I saved all these image structures in.... This is known as the "cookie-cutter" technique. Thanks to someone from Commodore for describing it to me. It's yecksellent having Commodore Tech people on the Net! On the screen, let's say I click at x=400, y=100. My algorithm goes thusly: 1. Which rectangles (captured above) contain that point? 2. Of those rectangles, which one has a 1 bit in the position in question (there can be one and only one)? 3. Bingo! I have found an object! I decided to use this technique because once I've clicked on an object I wanted it to flash, by xor'ing the cookie's bitmap with the proper location and planes in the screen's bitmap. So I knew I was gonna have to make the cookies anyway. -Mike Schwager