AddColor Resources

How AddColor is applied

AddColor can not be emulated as native color information and drawn with each part as it is drawn. Just by looking at the "Color Tools" stack that came with HyperCard, it becomes obvious that a lot of trickery like opaque buttons is used to hide B/W parts, while not covering the color on the same layer.

AddColor drew its colors in the correct order, back-to-front, background layer, then card layer, into a separate "color overlay" buffer. Then, the color overlay was merged with the B/W card contents using the "or" pen mode, effectively producing a "darken only" pen mode effect and replacing all white parts with pixels from the color buffer, while leaving the black parts untouched.

The AddColor XCMD could be used to refresh the color buffer contents on card changes, display visual effects on card changes or other occasions, and to add/delete/hide/show color elements, which were essentially independent of the real HyperCard objects.

General structure

For each background/card there is a corresponding 'HCbg' resp. 'HCcd' resource, with the same ID as that object, containing one entry for each object on the card or background. The resource simply contains one object entry after the other, until the end of the resource, in big-endian byte order:

1 byteObject type
High bit is hidden flag
n bytesObject-specific data

 
There are certain recurring data types in these blocks: The bevel is for a highlight/shadow effect at the upper left / lower right edges of the object, and is measured in pixels. Colors are stored as standard Quickdraw RGBColors. Extents of objects are stored as Quickdraw Rects.

There are four kinds of objects, each of which has a different block layout. Here's the layouts of each one:
 
Button:

1 byteObject type 0x01
High bit is hidden flag
2 bytesButton ID
2 bytesBevel
2 bytesRed Value (0...65535)
2 bytesGreen Value (0...65535)
2 bytesBlue Value (0...65535)
 
Button objects take their rectangles from the button with the specified ID on that card or background.
 
Field:
1 byteObject type 0x02
High bit is hidden flag
2 bytesButton ID
2 bytesBevel
2 bytesRed Value (0...65535)
2 bytesGreen Value (0...65535)
2 bytesBlue Value (0...65535)
 
Field objects take their rectangles from the field with the specified ID on that card or background.
 
Rectangle:
1 byteObject type 0x03
High bit is hidden flag
2 bytesTop coordinate
2 bytesLeft coordinate
2 bytesBottom coordinate
2 bytesRight coordinate
2 bytesBevel
2 bytesRed Value (0...65535)
2 bytesGreen Value (0...65535)
2 bytesBlue Value (0...65535)
 
A rectangle is simply a colored rectangular surface that can be arbitrarily positioned on a card or background.
 
Picture:
1 byteObject type 0x04
High bit is hidden flag
2 bytesTop coordinate
2 bytesLeft coordinate
2 bytesBottom coordinate
2 bytesRight coordinate
1 byteBoolean transparent
1 byteLength of image name
n bytesImage name
 
Picture objects can show a picture either with white areas being transparent (so other colored content can be seen through the gaps, or completely opaque regarding other AddColor objects. If there is a resource of the given name, it will be displayed, otherwise it will look for a file. using the given HFS file- or pathname.
 

Written up by Mister Z.