home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / next / programm / 7824 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.5 KB

  1. Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!hp-cv!hplabs!nsc!decwrl!adobe!usenet
  2. From: byer@adobe.com (Scott Byer)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: hit detection in user paths
  5. Message-ID: <1992Dec18.190719.22432@adobe.com>
  6. Date: 18 Dec 92 19:07:19 GMT
  7. Article-I.D.: adobe.1992Dec18.190719.22432
  8. References: <1gr6eaINNi4c@morrow.stanford.edu>
  9. Sender: usenet@adobe.com (USENET NEWS)
  10. Reply-To: byer@adobe.com (Scott Byer)
  11. Organization: Adobe Systems Incorporated
  12. Lines: 63
  13.  
  14. minch@lotka.stanford.edu writes
  15.  
  16. > I've got some big irregular shapes that I fill with user paths.
  17. > Now I want to find which big irregular shape the mouse is clicked
  18. > in. I look at DPSUserPath and find that dps_ufill is an allowable
  19. > action, but DPSUserPath itself is declared as void. So how does
  20. > the boolean get returned? Presumably it's left on the stack and I
  21. > can maybe pick it up using some dps stack snooper, but is there a
  22. > better way?
  23.  
  24. Ah, yes, the "in" operators.  Specifically, you're looking for
  25. "inufill".  There are two forms of inufill, depending on how you
  26. want to use the hit detection.  The first form is:
  27.  
  28. x y userpath inufill bool
  29.  
  30. The second is:
  31.  
  32. userpath userpath inufill bool
  33.  
  34. The first userpath can then be an aperature to be checked for
  35. intersection (say, an aperature around the mouse click - NOTE: you
  36. might as well make this aperature *round*, as it costs almost
  37. nothing in terms of performance, and gives a more natural feel to
  38. selection.)
  39.  
  40. There will be several ways of using inufill in combination with
  41. DPSDoUserPath, and if you really care about performance, testing
  42. the several variations might be in order.  Since this is off the
  43. top of my head, I'll try and keep it simple so I don't screw up.
  44. This example also happens to require a minimal amount of explanation
  45. :-)
  46.  
  47. /* Wraps. */
  48.  
  49. defineps checkfill( | boolean *hit; )
  50.     myPath1 myPath2 inufill hit
  51. endps
  52.  
  53. defineps putname( char *thename )
  54.     /thename
  55. endps
  56.  
  57. /* C code calling sequence. */
  58.  
  59. ..
  60.    boolean    answer;
  61.    ...
  62.    putname("myPath1");
  63.    DPSDoUserPath(..., dps_def);
  64.    putname("myPath2");
  65.    DPSDoUserPath(..., dps_def);
  66.    checkfill(&answer);
  67. ..
  68.  
  69. For a much better example, see Chapter 8 of the Purple book.
  70.  
  71. --
  72. Scott Byer                             NeXTMail: byer@mv.us.adobe.com
  73. Adobe Systems Incorporated               These are *my* opinions, and  
  74. 1585 Charleston Road, P.O. Box 7900        do not necessarily reflect
  75. Mountain View, CA 94039-7900             the opinions of my employer.
  76. ---------------------------------------------------------------------
  77.