[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: point-in-pict-p



On Thu Jan 26, Richard Lynch asks:
  Given a pict that was formed with, say:
  
   (* ...code to generate a picture and store it in pict  *)
  I need a function that will return non-NIL for those pixels actually
  covered by the rectangle, but NIL for those points inside the rectangle.
    
  ie, (point-in-pict-p pict #@(12 12)) --> T [or any non-NIL]
      (point-in-pict-p pict #@(24 24)) --> NIL
 
  Is there some easy way to do this?

Here's the function point-in-pict-p. Obviously, the function can be
protected by checking to see whether the picture is really a picture.
Here's the code that does what you want, I haven't tested it.


mark

(unless (fboundp 'ccl::valid-picture)
  (defun ccl::valid-picture (the-picture)
    (and (macptrp the-picture) (handlep the-picture) the-picture))
  (export 'ccl::valid-picture :ccl))

(defun point-in-picture-p (picture h &optional v)    
     (when (valid-picture picture)
              (rlet ((r :rect :topLeft (rref picture :picture.picframe.TopLeft)
                     :bottomRight (rref picture :picture.picframe.BottomRight)))
           (point-in-rect-p r point)))