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

Re: point-in-pict-p

In article <lynch-1701950000480001@>, lynch@ils.nwu.edu
(Richard Lynch) wrote:

> Given a pict that was formed with, say:
> ;untested code...
> (#_OpenPict ...)
> (#_PenSize 5 5)
> (#_PenMode #$srcOr)
> (rlet ((rect :topleft #@(10 10) :botright #@(50 50)))
>   (#_FrameRect rect))
> (setq pict (#_ClosePict))
> 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?
> -- "TANSTAAFL"  Rich lynch@ils.nwu.edu


to do it *right* you would need to know the "mask" for the picture being
drawn, that is all of the bits in the picture's rectangle that would
change were the picture drawn. okay, i know that's not *exactly* what the
mask is, but let's go on anyway. that mask would probably exist as a
region or a bitmap (which you can convert to a region), and then checking
if a point is in a region is easy: (#_PtInRgn point region)

however, i don't know of any easy way to get the mask. if you can assume
the following, you can do sort of a skanky thing:

1 - the background over which the picture is drawn is of a solid, uniform color
2 - everything drawn as part of the picture actually changes the pixel's
    appearance (either color or b/w)

in other words, let me explain by example. suppose we have a window with a
solid gray background. now we draw the picture in question which is the
rectangle picture you described above. given a point to check, we can do
the following: get the pixel value at the point in question (color or b/w)
and compare that to the background pixel value. if they're not the same,
you hit the picture; if equal, you missed the picture.

like i said, that's pretty skanky, but given your situation it may work. i
don't know of any easy way to determine whether a given pixel is actually
part of a picture or not. the picture utility stuff that came with system
7 doesn't even seem to include anything that you can use for this.

let me know if you need more help...

Joey Gray                       | geek@nwu.edu
School of Education             | (708) 467-1704
Northwestern University         +------------------------------------
**Bandwagon disclaimer:         | "Anybody can cook with gas --
   My opinions are mine, not my |  it takes the French to cook with
   employer's. so there!        |  magnets!" - old newsreel