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

Re: Pattern clarification

At  3:02 AM 7/22/93 -0600, osiris@cs.utexas.edu wrote:
>(setf xxx (make-instance 'window :color-p T))
>(with-focused-view xxx
>  (with-fore-color (make-color 0 40000 40000)
>    (pen-normal xxx)
>    (rlet ((old-pen :PenState))
>      (pen-state xxx old-pen)
>      (set-pen-pattern xxx *gray-pattern*)
>      (set-pen-size  xxx (make-point 5 5))
>      (move-to xxx 0 30)
>      (line-to xxx 200 30)
>      (set-pen-pattern xxx (rref old-pen :PenState.PnPat))
>      (move-to xxx 0 50)
>      (line-to xxx 200 50))))
>It's back...
>This code works.=, but it probably shouldn't  Apparently pen-pattern will
>only return a 64-bit black and white pattern, so if you call it on a color
>window, it won't return the appropriate PixPat.  However, contrary to the
>docs, set-pen-pattern will take a PixPat and do the right thing, so I used
>it here.  
>Are pen-pattern and set-pen-pattern supposed to work for color windows, or
>is it necessary to go through getting and setting the pen-state to mess
>with the pen patterns for color windows?

You're slightly misunderstanding what's going on here (as did I until I tried
your code and thought about it a while). *GRAY-PATTERN* is a 64-bit black-and-white
pattern. SET-PEN-PATTERN knows how to convert one of these for use in a color
window. PEN-STATE converts the color pattern in a color window into black-and-white
and stored it in your OLD-PEN record. (rref old-pen :PenState.pnPat) gets you
a black-and-white pattern, which SET-PEN-PATTERN converts for the color window.
Hence, your code doesn't use any color patterns anywhere.

To really work with color patterns, you need to use #_PenPixPat and
(pref (wptr w) :CGrafPort.pnPixPat. For safety, it would be best to
test for WINDOW-COLOR-P before using the color traps. Note that warning
in Inside Mac that #_PenPixPat doesn't copy the PixPat that you give it,
so you must be careful not to dispose of it and not be surprised when it
gets disposed when you close the window (Hence, I'd suggest copying the
pixpat with #_CopyPixPat before before installing it in the window with

As I believe I said recently, "ccl:examples;quickdraw.lisp" has no color specific code.
Because color windows support all of the black-and-white traps, it will work in
a color window. COPY-BITS will work with pixmaps because #_CopyBits does.