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

Re: Color QuickDraw in MCL 2.0



At  6:58 AM 10/18/93 +0000, Lin@news.cambridge.apple.com, Chien Chang wrote:
>I have tried to make an instance of CWindow with the following
>expressions:
>
>(setq a (make-instance 
>
>and this should create a color window, but when I tried to draw a
>rectangle on the window, it didn`t work and just draw a black rectangle,
>can any body tell me why?
>
>The testing code is as follows:
>
>(rlet ((testcolor :RGBColor :red 1000 :green 1000 :blue 1000)
>        (r :rect :top 0 :left 0 :right 100 :bottom 100))
>        (with-focused-view a 
>                (#_rgbforecolor testcolor)
>                (#_paintrect r)))

Your code gives me a black rectangle as well. The problem is that
though color quickdraw has a 48 bit color space, with 16 bits for each
of red, green, & blue, most display devices support only a 24-bit
color space, with 8 bits for each primary color. The top 8 bits
of each of the quickdraw color values are used. Hence, values below 256
are effectively 0, and 1000 maps to 3 out of 256, which is very dark. Add
to this the fact that many display cards can display only 256 colors at a
time, and the fact that black is the closest color to your color in the
system color table, and you've got your answer: use more saturated colors,
i.e. color values closer to 65536. The following code draws a bright red
rectangle:

(rlet ((testcolor :RGBColor :red 65535 :green 0 :blue 0)
        (r :rect :top 0 :left 0 :right 100 :bottom 100))
        (with-focused-view a 
                (#_rgbforecolor testcolor)
                (#_paintrect r)))

You'll have an easier time if you use MCL color values, which pack
24 bits of color info into a fixnum. SET-FORE-COLOR, SET-BACK-COLOR,
WITH-FORE-COLOR, & WITH-BACK-COLOR take these color fixnums as an
argument. USER-PICK-COLOR, MCL's interface to the color picker, also
returns a color fixnum.