Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!ogicse!pdxgate!eecs!bairds From: bairds@eecs.cs.pdx.edu (Shawn L. Baird) Newsgroups: comp.sys.amiga.programmer Subject: Re: Clicking on irregular shapes? Message-ID: <2151@pdxgate.UUCP> Date: 30 Mar 91 23:49:27 GMT References: <1991Mar27.212214.6204@orfeo.radig.de> <2710@sirius.ucs.adelaide.edu.au> <20181@cbmvax.commodore.com> <1991Mar29.022042.14110@leland.Stanford.EDU> <1757.tnews@templar.actrix.gen.nz> Sender: news@pdxgate.UUCP Lines: 33 jbickers@templar.actrix.gen.nz (John Bickers) writes: >Quoted from <1991Mar29.022042.14110@leland.Stanford.EDU> by mmaston@leland.Stanford.EDU (Michael Maston): >> object on the screen has been chosen by a mouse-click. Now this is pretty >> straightforward for boxes, lines, circles and even ellipses, but how does >> one do this with say an object drawn with a freehand tool? I have >> experimented > One approach is to determine if the point is within a polygon or > not. First check the point against the extent of the polygon, and > if it's in, then count how many edges of the polygon a line from > the point to one edge of the screen intersects. > Odd and it's inside, even and it's outside. If you're really lazy and don't mind wasting a little extra memory, or if your objects have non-polygon shapes, try setting up a one plane mask of the area. Then just check the point to see if it is a 1 or a 0 when clicking occurs inside of the box. (This could even be an extension to normal Intuition buttons. Just set up the mask and a pointer to it as part of the structure and then check it whenever you get the appropriate event) When I said lazy up above, essentially I mean quick. The memory loss isn't usually tremendous either. Note: This is just an idea. Never tried it, but I have thought about it before and this seemed like a fairly straight forward and yet powerful way to accomplish it. This way you can have holes in buttons or pieces of buttons (that is, maybe the button is broken into two distinct pieces, neither of which connects with the other). --- Shawn L. Baird, bairds@eecs.ee.pdx.edu, Wraith on DikuMUD The above message is not licensed by AT&T, or at least, not yet.