TweetFollow Us on Twitter

Color Capable
Volume Number:3
Issue Number:7
Column Tag:Macintosh II

Lazy Man's Color

By Steven Sheets, Hoffman Estates, IL

Newsbreak....Cupertino, Calif.....Color is here!

The new Macintosh // computer has color capabilities. Most color video cards will allow up to 256 specific colors out of a possible color palatte of 16,777,216 selections. A new Color Quickdraw has been designed with Color Tables, Pixel Maps, Pixel Patterns, Color Icons, Color Grafports and Color Picture Handles to work with the new machine. Three new Managers have been added to facilitate color; the Color Manager, the Color Picker Package and the Palette Manager.

Are you ready to program with this new Color Quickdraw?

Before you answer that, did you know there was an alternative way to display color on the Mac? Use the old Quickdraw color routine! You didn’t know the older Quickdraw had color? Well...

Old Color

The original Macintosh displays were in black & white. 21,888 bytes of memory were used to display the normal 512 by 342 pixel screen (1 bit per pixel). However, the original Quickdraw had the capability to draw in color. In the original Grafport record, there were 2 fields (fgColor and bkColor) that determined the settings of the Foreground and Background color.

Quickdraw predefined 8 colors (Black, White, Red, Green, Blue, Cyan, Magenta and Yellow). Each color had a long integer constant associated with it. By passing these constants to the procedures ForeColor and BackColor, the respective fields of the current Grafport were changed. When any Grafport was created, the default settings for the Foreground and Background were Black and White respectively.

Color fields were treated similar to the more often used Pen Pattern (pnPat) and Background Pattern (bkPat). Any drawing by the Pen was done in the Foreground color, any Erasing was done in the Background color. Also Foreground and Background color affect the Copybits call. When copying a bitmap onto a Grafport, any bit that was set in the source Bitmap would make the corresponding pixel appear in the Foreground color on the Grafport. Any unset bit would make the pixel appear in the Background color.

However on the black and white Macintosh, any color other than white appears as black. Thus drawing Red on White, Blue on White, or even Yellow on White has the same effect on the Pre-Mac // computers; Black on White. Interestingly the Imagewriter // printer driver does use the color commands, thus making the Imagewriter // with a color ribbon the first color Macintosh output device of any type. While the new Mac // also has the new Color Quickdraw commands, it also supports the old commands, including the use of Foreground and Background color.

Fig. 1 Our program uses classic color options

Why Use Old?

There are several reasons for not wanting to use Color Quickdraw for your first color program. It might prove simpler, until you get a handle on Color Quickdraw (and the three associated managers), to use the older Quickdraw routines. Color Quickdraw involves new conceptional models, new data structures, and new routines. While it is well worth the effort to learn (the graphic effects are stunning), there is a stiff learning curve.

The Color Quickdraw manual is even larger than the original Quickdraw manual. That is assuming that you have the new documentation. Inside Macintosh Vol. V is due out soon, but unless you currently have a beta version, you will have to wait for APDA’s final release.

Even if you have the new documentation and routines, your development system may not implement the new ROM calls. Lightspeed C, Lightspeed Pascal, MDS do not support the new Quickdraw, while MPW has to be updated to version 2.0. Many programmers will have to wait until the developers of their programming language come out with a new update until they can use the new routines. Some lucky users can input all the new calls themselves and do not need the updates. That means typing in dozens of new calls and data structures (again assuming they have the documentation). Lucky them! [Apple is still working on the equates file and rumor has it the Pallette Manager is still changing. -Ed]

Finally there is the actual code size and time in involved programming the new Quickdraw. Color Quickdraw does take more code to implement and it’s data structures are larger. The simple ForeColor and BackColor routines take very little code space.

Certainly Color Quickdraw should be used if someone is writing a color Drawing program for the Mac //. But if you only wish to add color to your existing programs, using Color Quickdraw requires you to rewrite your code, redo your graphics and in some cases, even redo your complicated bitmaps. Placing ForeColor and BackColor calls before your existing code segments is much simpler. If your Program is intended to run on any Macintosh, the older Quickdraw may be all you need or want to produce color.

The Code

The source example is an extremely simple, standard Macintosh program. It loads and displays any MacPaint document in any of the eight Foreground and eight Background colors. A few notes:

1) The CWindow (which will display the MacPaint document) is centered on large screens (like a SuperMac monitor) or placed in the offset position.

2) The actual picture is stored in two sets of Bitmaps and Data handles. Data is stored this way since the size of a MacPaint bitmap is too large to store in 1 set (32K limit). If there is not enough memory to create the bitmaps, the program will state this and not allow a MacPaint document to be loaded

3) ForeC and BackC store the selected menu number (1-8), not the predefined Color constant. GetColor is used to convert the menu number into the color constant.

4) DoColor is the pivotal procedure; it sets the new Foreground/Background colors. Then it causes an window update so the window is redrawn in the new colors.

{Lazy Man’s Color by Steve Sheets 4/20/87 }
{Simple Demonstration of Mac // Color using the 
{ForeColor & BackColor of classical Quickdraw. }
{This program Loads and displays a MacPaint document }
(in any 2 colors.}


{Various Constants:Menu ID Numbers, Window Size, }
{Window Placement, BitMap Size and Number of Colors. }
 AppleMenuID = 300;
 FileMenuID = 301;
 EditMenuID = 302;
 ForeMenuID = 303;
 BackMenuID = 304;

 OffV = 40;
 OffH = 40;
 AboutH = 300;
 AboutV = 140;
 SizeH = 576;
 SizeV1 = 360;
 SizeV2 = 720;
 BitW = 72;
 NumSec = 2;

 XColor = 8;

{Various Variables:Menus, Bitmaps, Window, Colors, }
{Done Flag & Title Name }
 Done : boolean;
 AppleMenu, FileMenu: EditMenu, 
 ForeMenu, BackMenu : MenuHandle;

 CWindow : windowptr;
 CMap : ARRAY[1..NumSec] OF bitmap;
 CData : ARRAY[1..NumSec] OF handle;

 ForeC, BackC : integer;
 Title : str255;

{Given Color Number ( 1 to XColor, as selected by Menu), }
{returns actual longint Color Number (for ForeColor or }
{BackColor). }
FUNCTION GetColor (N : integer) : longint;
 1 : 
 GetColor := BlackColor;
 2 : 
 GetColor := WhiteColor;
 3 : 
 GetColor := RedColor;
 4 : 
 GetColor := GreenColor;
 5 : 
 GetColor := BlueColor;
 6 : 
 GetColor := CyanColor;
 7 : 
 GetColor := MagentaColor;
 8 : 
 GetColor := YellowColor;
 GetColor := WhiteColor;

{Sets new ForeColor & BackColor and forces an Update} 
{so Window is redrawn in the new colors. }
PROCEDURE DoColor (F, B : integer);
 count : integer;
 tempPort : Grafptr;
 IF F <> ForeC THEN
 FOR count := 1 TO XColor DO
 CheckItem(ForeMenu, count, count = F);
 ForeC := F;
 IF B <> BackC THEN
 FOR count := 1 TO XColor DO
 CheckItem(BackMenu, count, count = B);
 BackC := B;

{ Loads MacPaint Picture in Bitmaps and displays it.}
 diskBlock = PACKED ARRAY[1..512] OF QDbyte;
 MyReply : SFReply;
 MyType : SFtypelist;
 tempPoint : point;
 count : longint;
 refNum, scanline, N : integer;
 error : OSErr;
 srcBuf : ARRAY[1..2] OF diskBlock;
 srcPtr, dstPtr : Ptr;
 tempPoint.v := 60;
 tempPoint.h := 60;
 MyType[0] := ‘PNTG’;
 SFGetFile(tempPoint, ‘’, NIL, 1, MyType, NIL, MyReply);
 IF MyReply.good THEN
 IF FSOpen(MyReply.fname, MyReply.vrefnum, refNum) = noErr THEN
 count := 512;
 error := FSRead(refNum, count, @srcBuf);
 count := 1024;
 error := FSRead(refNum, count, @srcBuf);
 srcPtr := @srcBuf;
 FOR N := 1 TO NumSec DO
 dstPtr := CData[N]^;
 FOR scanline := 1 TO SizeV1 DO
 UnpackBits(srcPtr, dstPtr, BitW);
 IF ord(srcPtr) > (ord(@srcBuf) + 512) THEN
 srcBuf[1] := srcBuf[2];
 count := 512;
 error := FSRead(refNum, count, @srcBuf[2]);
 srcPtr := pointer(ord(srcPtr) - 512);
 error := FSClose(refNum);
 DoColor(ForeC, BackC);

{Creates a Rectangle centered on Screen (if window }
{size is smaller then the screen) or starting at a }
{standard offset (if window size is larger then }
{screen). }
PROCEDURE CenterRect (VAR R : rect;
 H, V : integer);
 tempH : integer;
 IF H > Screenbits.bounds.right THEN
 tempH := OffH
 tempH := ((Screenbits.bounds.right - H) DIV 2);
 SetRect(R, tempH, OffV, H + tempH, V + OffV);

{Draws text, centered in a rectangle in the About}
{  Box window in a certain color with a certain }
{justification }
PROCEDURE DoLine (S : str255;
 H, Top, Bottom, J : integer;
 C : longint);
 tempInteger : integer;
 tempRect : rect;
 tempInteger := ((AboutH - H) DIV 2);
 SetRect(tempRect, tempInteger, Top, tempInteger + H, Bottom);
 TextBox(POINTER(ord(@S) + 1), LENGTH(S), tempRect, J);

{Displays About Box (in color) until someone presses } 
{the button down.}
 tempWindow : windowptr;
 tempRect : rect;
 tempStr : str255;
 CenterRect(tempRect, AboutH, AboutV);
 tempWindow := NewWindow(NIL, tempRect, ‘’, true, dBoxProc, POINTER(-1), 
false, 0);

 DoLine(CONCAT(Title, ‘ by Steve Sheets’), AboutH, 20, 39, teJustCenter, 
 DoLine(‘Sample Mac // Color Program’, AboutH, 40, 59, teJustCenter, 
 DoLine(‘This program uses the ForeColor and BackColor Quickdraw commands 
to display a MacPaint document in two colors.’, AboutH - 50, 60, AboutV, 
teJustLeft, RedColor);

 WHILE NOT button DO

{Standard main menu procedure that handles }
{menu selections.  Can show About Box, open Desk }
{Accessories, Load in MacPaint file, change }
{the Done Flag (so the program quits), handle} 
{edit commands (Cut,Copy,Paste,Clear), and change }
{Foreground or Background color of the picture.}
PROCEDURE MainMenu (tempResult : LONGINT);
 tempInteger : integer;
 tempBoolean : boolean;
 tempStr : STR255;
 tempInteger := LoWord(tempResult);
 CASE HiWord(tempResult) OF
 AppleMenuID : 
 IF tempInteger = 1 THEN
 GetItem(appleMenu, tempInteger, tempStr);
 tempInteger := OpenDeskAcc(tempStr);
 FileMenuID : 
 CASE tempInteger OF
 1 : 
 3 : 
 Done := true;
 EditMenuID : 
 tempBoolean := SystemEdit(tempInteger - 1);
 ForeMenuID : 
 IF (tempInteger > 0) AND (tempInteger <= XColor) THEN
 DoColor(tempInteger, BackC);
 BackMenuID : 
 IF (tempInteger > 0) AND (tempInteger <= XColor) THEN
 DoColor(ForeC, tempInteger);

{Setup for Menus, Window, Bitmaps,  Colors }
{settings, Title and Done flag.  }
 DD = PACKED ARRAY[1..32000] OF 0..255;
 PP = ^DD;
 HH = ^PP;
 tempStr : STR255;
 tempRect : rect;
 count : integer;
 tempLong : longint;
 tempH : HH;
 Title := ‘Lazy Man@s Color’;
 Title[9] := CHR(39);

 tempStr := ‘ ‘;
 tempStr[1] := CHR(appleMark);
 AppleMenu := NewMenu(AppleMenuID, tempStr);
 AppendMenu(AppleMenu, CONCAT(‘About ‘, Title, ‘...;(-’));
 AddResMenu(AppleMenu, ‘DRVR’);

 FileMenu := NewMenu(FileMenuID, ‘File’);
 AppendMenu(FileMenu, ‘Load MacPaint Documents/L;(-;Quit/Q’);

 EditMenu := NewMenu(EditMenuID, ‘Edit’);
 AppendMenu(EditMenu, ‘Undo/Z;(-;Cut/X;Copy/C; Paste/V;Clear’);

 ForeMenu := NewMenu(ForeMenuID, ‘Set Foreground’);
 AppendMenu(ForeMenu, ‘Black;White;Red;Green;Blue; Cyan;Magenta;Yellow’);

 BackMenu := NewMenu(BackMenuID, ‘Set Background’);
 AppendMenu(BackMenu, ‘Black;White;Red;Green;Blue;Cyan; Magenta;Yellow’);

 InsertMenu(AppleMenu, 0);
 InsertMenu(FileMenu, 0);
 InsertMenu(EditMenu, 0);
 InsertMenu(ForeMenu, 0);
 InsertMenu(BackMenu, 0);


 CenterRect(tempRect, SizeH, SizeV2);
 CWindow := NewWindow(NIL, tempRect, Title, true, 4, POINTER(-1), false, 

 CMap[1].rowBytes := BitW;
 SetRect(CMap[1].bounds, 0, 0, SizeH, SizeV1);
 CData[1] := NewHandle(BitW * SizeV1);
 IF CData[1] <> NIL THEN
 tempH := HH(CData[1]);
 FOR count := 1 TO BitW * SizeV1 DO
 tempH^^[count] := 0;
 CMap[2].rowBytes := BitW;
 SetRect(CMap[2].bounds, 0, SizeV1, SizeH, SizeV2);
 CData[2] := NewHandle(BitW * SizeV1);
 IF CData[2] <> NIL THEN
 tempH := HH(CData[2]);
 FOR count := 1 TO BitW * SizeV1 DO
 tempH^^[count] := 0;
 IF (CData[1] = NIL) OR (CData[2] = NIL) THEN
 SetWTitle(CWindow, ‘Not Enough Memmory’);
 DisableItem(FileMenu, 1);
 ForeC := 0;
 BackC := 0;
 DoColor(1, 2);
 Done := false;

{Standard main program loop that handles all }
{events (ie. mouse down, key downs & updates) until }
{the Done flag is set.  }
 tempEvent : EventRecord;
 tempWindow : windowptr;
 tempCode : integer;
 tempPort : Grafptr;
 tempRect : rect;
 IF GetNextEvent(everyEvent, tempEvent) THEN
 CASE tempEvent.what OF
 mouseDown : 
 tempCode := FindWindow(tempEvent.where, tempWindow);
 CASE tempCode OF
 inDrag, inContent : 
 IF tempWindow <> FrontWindow THEN
 IF Cwindow = tempWindow THEN
 IF CWindow <> FrontWindow THEN
 SetRect(tempRect, -25000, -25000, 25000, 25000);
 DragWindow(CWindow, tempEvent.where, tempRect);
 inMenuBar : 
 inSysWindow : 
 SystemClick(tempEvent, tempWindow);
 END; { of tempCode case }
 END; { of mouseDown }
 keydown, autoKey : 
 IF BitAnd(tempEvent.modifiers, cmdKey) <> 0 THEN
 MainMenu(MenuKey(CHR(tempEvent.message MOD 256)));
 updateEvt : 
 IF CWindow = WindowPtr(tempEvent.message) THEN
 IF CData[1] <> NIL THEN
 CMap[1].baseAddr := CData[1]^;
 CopyBits(CMap[1], CWindow^.portBits, CMap[1].bounds, CMap[1].bounds, 
srcCopy, NIL);
 IF CData[2] <> NIL THEN
 CMap[2].baseAddr := CData[2]^;
 CopyBits(CMap[2], CWindow^.portBits, CMap[2].bounds, CMap[2].bounds, 
srcCopy, NIL);
 UNTIL Done;

{***PROGRAM*** }

Community Search:
MacTech Search:

Software Updates via MacUpdate

Vivaldi 2.6.1566.49 - An advanced browse...
Vivaldi is a browser for our friends. We live in our browsers. Choose one that has the features you need, a style that fits and values you can stand by. From the look and feel, to how you interact... Read more
Capo 3.7.4 - Slow down and learn to play...
Capo lets you slow down your favorite songs so you can hear the notes and learn how they are played. With Capo, you can quickly tab out your songs atop a highly-detailed OpenCL-powered spectrogram... Read more
Daylite - Dynamic business organ...
Daylite helps businesses organize themselves with tools such as shared calendars, contacts, tasks, projects, notes, and more. Enable easy collaboration with features such as task and project... Read more
Firefox 68.0.1 - Fast, safe Web browser.
Firefox offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals and casual... Read more
Dashlane 6.1927.0 - Password manager and...
Dashlane is an award-winning service that revolutionizes the online experience by replacing the drudgery of everyday transactional processes with convenient, automated simplicity - in other words,... Read more
BetterTouchTool 3.153 - Customize multi-...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom)... Read more
calibre 3.46.0 - Complete e-book library...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital librarian... Read more
DEVONthink Pro 3.0beta4 - Knowledge base...
DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research papers, your life often fills your hard drive in the... Read more
Adobe Creative Cloud - Access...
Adobe Creative Cloud costs $20.99/month for a single app, or $52.99/month for the entire suite. Introducing Adobe Creative Cloud desktop applications, including Adobe Photoshop CC and Illustrator CC... Read more
Chromium 75.0.3770.142 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. Version 75.0.3770.142: Release notes were... Read more

Latest Forum Discussions

See All

Void Tyrant guide - Tips and tricks for...
Void Tyrant continues to get a lot of play in these parts. Probably because the game is just so deep and varied. The next stop on our guide series for Void Tyrant is class-specific guides. First up is the Knight, as it’s the first class anyone has... | Read more »
Summon beasts and battle evil in epic re...
Imagine a tale of conlict between factions of good and evil, where rogueish heroes summon beasts to aid them in them in warfare and courageously battle dragons over fields of scorched earth and brimstone - that's exactly the essence of epic fantasy... | Read more »
Upcoming visual novel Arranged shines a...
If you’re in the market for a new type of visual novel designed to inform and make you think deeply about its subject matter, then Arranged by Kabuk Games could be exactly what you’re looking for. It’s a wholly unique take on marital traditions in... | Read more »
TEPPEN guide - The three best decks in T...
TEPPEN’s unique take on the collectible card game genre is exciting. It’s just over a week old, but that isn’t stopping lots of folks from speculating about the long-term viability of the game, as well as changes and additions that will happen over... | Read more »
Intergalactic puzzler Silly Memory serve...
Recently released matching puzzler Silly Memory is helping its fans with their intergalactic journeys this month with some very special offers on in-app purchases. In case you missed it, Silly Memory is the debut title of French based indie... | Read more »
TEPPEN guide - Tips and tricks for new p...
TEPPEN is a wild game that nobody asked for, but I’m sure glad it exists. Who would’ve thought that a CCG featuring Capcom characters could be so cool and weird? In case you’re not completely sure what TEPPEN is, make sure to check out our review... | Read more »
Dr. Mario World guide - Other games that...
We now live in a post-Dr. Mario World world, and I gotta say, things don’t feel too different. Nintendo continues to squirt out bad games on phones, causing all but the most stalwart fans of mobile games to question why they even bother... | Read more »
Strategy RPG Brown Dust introduces its b...
Epic turn-based RPG Brown Dust is set to turn 500 days old next week, and to celebrate, Neowiz has just unveiled its biggest and most exciting update yet, offering a host of new rewards, increased gacha rates, and a brand new feature that will... | Read more »
Dr. Mario World is yet another disappoin...
As soon as I booted up Dr. Mario World, I knew I wasn’t going to have fun with it. Nintendo’s record on phones thus far has been pretty spotty, with things trending downward as of late. [Read more] | Read more »
Retro Space Shooter P.3 is now available...
Shoot-em-ups tend to be a dime a dozen on the App Store, but every so often you come across one gem that aims to shake up the genre in a unique way. Developer Devjgame’s P.3 is the latest game seeking to do so this, working as a love letter to the... | Read more »

Price Scanner via

Weekend Deal: 2018 13″ MacBook Airs starting...
B&H Photo has clearance 2018 13″ MacBook Airs available starting at only $999 with all models now available for $200 off Apple’s original MSRP. Overnight shipping, or expedited shipping, is free... Read more
Apple has clearance 10.5″ iPad Pros available...
Apple has Certified Refurbished 2017 10.5″ iPad Pros available starting at $469. An Apple one-year warranty is included with each iPad, outer shells are new, and shipping is free: – 64GB 10″ iPad Pro... Read more
Apple restocks refurbished iPad mini 4 models...
Apple has restocked Certified Refurbished 32GB iPad mini 4 WiFi models for $229 shipped. That’s $70 off original MSRP for the iPad mini 4. Space Gray, Silver, and Gold colors are available. Read more
Apple, Yet Again, Is Missing An Ultraportable...
EDITORIAL: 07.19.19 Prior to the decision made by Apple earlier this month to retire the thin and light MacBook model with a 12-inch retina display, the Cupertino, California-based company offered,... Read more
Verizon is offering a 50% discount on iPhone...
Verizon is offering 50% discounts on Apple iPhone 8 and iPhone 8 Plus models though July 24th, plus save 50% on activation fees. New line required. The fine print: “New device payment & new... Read more
Get a new 21″ iMac for under $1000 today at t...
B&H Photo has new 21″ Apple iMacs on sale for up to $100 off MSRP with models available starting at $999. These are the same iMacs offered by Apple in their retail and online stores. Shipping is... Read more
Clearance 2017 15″ 2.8GHz Touch Bar MacBook P...
Apple has Certified Refurbished 2017 15″ 2.8GHz Space Gray Touch Bar MacBook Pros available for $1809. Apple’s refurbished price is currently the lowest available for a 15″ MacBook Pro. An standard... Read more
Clearance 12″ 1.2GHz MacBook on sale for $899...
Focus Camera has clearance 12″ 1.2GHz Space Gray MacBooks available for $899.99 shipped. That’s $400 off Apple’s original MSRP. Focus charges sales tax for NY & NJ residents only. Read more
Get a new 2019 13″ 2.4GHz 4-Core MacBook Pro...
B&H Photo has new 2019 13″ 2.4GHz MacBook Pros on sale for up to $150 off Apple’s MSRP. Overnight shipping is free to many addresses in the US: – 2019 13″ 2.4GHz/256GB 6-Core MacBook Pro Silver... Read more
AirPods with Wireless Charging Case now on sa...
Amazon has extended their Prime Day savings on Apple AirPods by offering AirPods with the Wireless Charging case for $169.99. That’s $30 off Apple’s MSRP, and it’s the cheapest price available for... Read more

Jobs Board

Geek Squad *Apple* Master Consultation Agen...
**702908BR** **Job Title:** Geek Squad Apple Master Consultation Agent **Job Category:** Services/Installation/Repair **Location Number:** 000360-Williston-Store Read more
Best Buy *Apple* Computing Master - Best Bu...
**711023BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Location Number:** 000012-St Cloud-Store **Job Description:** **What does a Read more
*Apple* Systems Architect/Engineer, Vice Pre...
…its vision to be the world's most trusted financial group. **Summary:** Apple Systems Architect/Engineer with strong knowledge of products and services related to Read more
Best Buy *Apple* Computing Master - Best Bu...
**696259BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Location Number:** 001076-Temecula-Store **Job Description:** The Read more
Business Development Manager, *Apple* Globa...
Business Development Manager, Apple Global Tampa, FL, US Requisition Number:73805 As a Global Apple Business Development Manager at Insight, you proactively Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.