home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!hp-cv!hplabs!nsc!decwrl!adobe!usenet
- From: byer@adobe.com (Scott Byer)
- Newsgroups: comp.sys.next.programmer
- Subject: Re: hit detection in user paths
- Message-ID: <1992Dec18.190719.22432@adobe.com>
- Date: 18 Dec 92 19:07:19 GMT
- Article-I.D.: adobe.1992Dec18.190719.22432
- References: <1gr6eaINNi4c@morrow.stanford.edu>
- Sender: usenet@adobe.com (USENET NEWS)
- Reply-To: byer@adobe.com (Scott Byer)
- Organization: Adobe Systems Incorporated
- Lines: 63
-
- minch@lotka.stanford.edu writes
-
- > I've got some big irregular shapes that I fill with user paths.
- > Now I want to find which big irregular shape the mouse is clicked
- > in. I look at DPSUserPath and find that dps_ufill is an allowable
- > action, but DPSUserPath itself is declared as void. So how does
- > the boolean get returned? Presumably it's left on the stack and I
- > can maybe pick it up using some dps stack snooper, but is there a
- > better way?
-
- Ah, yes, the "in" operators. Specifically, you're looking for
- "inufill". There are two forms of inufill, depending on how you
- want to use the hit detection. The first form is:
-
- x y userpath inufill bool
-
- The second is:
-
- userpath userpath inufill bool
-
- The first userpath can then be an aperature to be checked for
- intersection (say, an aperature around the mouse click - NOTE: you
- might as well make this aperature *round*, as it costs almost
- nothing in terms of performance, and gives a more natural feel to
- selection.)
-
- There will be several ways of using inufill in combination with
- DPSDoUserPath, and if you really care about performance, testing
- the several variations might be in order. Since this is off the
- top of my head, I'll try and keep it simple so I don't screw up.
- This example also happens to require a minimal amount of explanation
- :-)
-
- /* Wraps. */
-
- defineps checkfill( | boolean *hit; )
- myPath1 myPath2 inufill hit
- endps
-
- defineps putname( char *thename )
- /thename
- endps
-
- /* C code calling sequence. */
-
- ..
- boolean answer;
- ...
- putname("myPath1");
- DPSDoUserPath(..., dps_def);
- putname("myPath2");
- DPSDoUserPath(..., dps_def);
- checkfill(&answer);
- ..
-
- For a much better example, see Chapter 8 of the Purple book.
-
- --
- Scott Byer NeXTMail: byer@mv.us.adobe.com
- Adobe Systems Incorporated These are *my* opinions, and
- 1585 Charleston Road, P.O. Box 7900 do not necessarily reflect
- Mountain View, CA 94039-7900 the opinions of my employer.
- ---------------------------------------------------------------------
-