Color Mixer
Volume Number: 4
Issue Number: 4
Column Tag: Basic School
Color Mixer Creates Custom Colors 
By Dave Kelly, MadTutor Editorial Board, Ontario, California
ZBasic Does Mac II Color!
Yes, that’s right! The new ZBasic version 4.01 now supports the Mac II’s full
256 colors. There is no need to restrict yourself to the 8 colors of the old Quickdraw.
To use the 256 color mode, ZBasic now provides a LONG COLOR statement. The
syntax is: LONG COLOR blue%, green%, red%, [ background]. LONG COLOR is used to
set the colors and grey levels for subsequent graphic commands used on the Macintosh
II. The command is ignored by other Macs.
The values of blue%, green% and red% may range from 0 to 65535. They may
also be represented as long integers (65535 as a long integer is -32767 as a regular
integer). The colors are used in RGBColor calls to the Mac II ROM where 0 is the
darkest and 65535 is the lightest.
The background variable is used as a flag to indicate if the color should be set in
the foreground or in the background. A background value of 0 causes the background
color to be set to the blue%, green%, red% color indicated. Subsequent LONG COLOR
statements that have no background variable or background is set to other than 0 will
set the foreground color. The background color will be used the next time it is needed,
when the screen gets updated or is cleared with CLS.
Inside Macintosh Volume V has the new color information we need to understand
how the Mac II gets its color and how to use color in your applications. Before using
color you should read the User Interface chapter of Inside Macintosh Vol. V. One of the
most important thing you should try do is leave the selection and choices of color in the
hands of the user. The study of color and how it affects people is not well defined. One
of my co-workers is color-blind and has a totally different way of looking at color than
I do. If color is not used carefully it could hinder instead of help to enhance your
software.
Traditionally (and on that other computer) color has been used to help
distinguish different things on the screen and show relationships between items on the
screen. Some colors have special significance. For example: red means stop, green
means go, yellow means caution. Colors can enhance in this way, however, remember
that after the user has seen the same color combinations several dozen times, the color
becomes commonplace and he might still make mistakes that the color was supposed to
help him avoid. In fact, the bright colors used to warn a user may actually attract him
to select that color.
Inside Mac encourages you to start out the design of your program in black and
white and add color as a supplement to provide extra for people who have color
capability. Color use should be limited to the content area of your windows. Let the
user decide what color his menus, borders, controls etc. should be. The Colorizer
application and CDEV let the user select his own colors for these items. If the user
selects colors for somethings then your application comes along and changes part of
these colors, there might be some pretty strange color combinations left over. Many
suggestions are available in Inside Mac which you should know so that your
applications will be consistent and won’t conflict with the user interface.
Fig. 1 Mixing colors, in this case white!
The blue%, green%, and red% that you specify in the LONG COLOR is used by the
Color Manager to return the pixel value that best represents that color. The Color
Manager searches through the color table for the RGB color that most closely matched
the desired color. Color Quickdraw then places that color on the screen. The way that
each pixel is assigned a color to display is by way of the Color Look-Up Table (CLUT).
The video card takes each pixel and compares it to the CLUT to determine which RGB
value that pixel represents. The RGB value is split off into three separate electrical
signals (red, green, and blue) to the video monitor. By the way, when red=green=blue
you get shades of gray. By using the Palette Manager (if you could from Basic) you
could change the drawing environment to use a different palette.
Color Selection
Color Selection routines have been provided to the Macintosh II by Apple via the
Color Picker routines. Here is the problem: ZBasic doesn’t support all the new calls
for the Mac II yet. Zedcor has promised to send me format and structure information to
add more calls to ZBasic as required, but Andy Gariepy has been to busy to send it to
me. So that being the case I have no choice but to write my own color selection
routines. Also the Color Picker is PACK_12 in system 4.2. I’m not sure it would be
that easy to call a PACKage from ZBasic without it being defined by the language itself.
Maybe we will have to wait for Zedcor to implement it. In the mean time I have made
my own “quick and dirty” version of a “Color Picker”.
If you think about it, the Apple Color Picker routine really does do a lot! It
allows you to type in the red, green, blue colors, but also will adjust these colors when
you set the hue, saturation, and brightness. Proper adjustment of the red, green, and
blue will result in the same hues, saturation, and brightness, but it just isn’t as
convenient to setup.
The color wheel concept is interesting too. You can learn a lot about how colors
can be mixed by watching the values of red, green, and blue while moving the mouse