previous chapter contents page top page next chapter

Color

October 5, 1992
last updated September 30, 1993

Defined in Style.Demf 
Inherits from Object
Collects members



Class Description

Every viewable object is drawn using at least one color. Because Magic Cap software often runs on a device with a screen that can't display colors, Magic Cap colors also include shades of gray. Objects of class Color specify an RGB value that can be used by the viewable object with which they're associated.

Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Using a Color Object

Color is a direct subclass of Object. Color objects encode their colors by storing an RGB value. The RGB value has four components: red, green, blue, and transparency. The red, green, and blue components each specify an intensity for those colors. The red, green, and blue intensity values combine to form a color.

Programming Information

Instantiate: rarely
Subclass: rarely
Call its methods: sometimes

The easiest way to change the colors of objects in your software is by dropping color coupons, available in the Magic Hat. You can also set colors of objects in object definition text files. To make coloring objects easier, the system defines class ColorBox, a palette of colors that produces color coupons. See the ColorBox chapter for more information.

The Color class defines a set of methods for getting and changing the RGB color represented by the object.

Methods you might call

The Color class has the following methods you might Call:

Method Description
RGB Returs the object's rgb color
SetRGB Set the object's rgb color

Description of fields

The Color class defines just one field:

Field Type Description
rgb Unsigned RGB value for color

Method Descriptions

RGBSetRGB

field rgb: Unsigned, getter, setter
// operation RGB: Unsigned
// operation SetRGB(newValue: Unsigned)

Call: sometimes
Override: rarely

Call RGB to return the color object's RGB color. Call SetRGB to set the color object's RGB color to the value in newValue. SetRGB simply stores newValue in the object's rgb field.

IsShared

overrides IsShared

Call: rarely
Override: rarely

In order to reduce the number of objects that must be kept in memory or sent to another device, the system defines a sharable object as one that can be substituted for another that appears to be the same. The system calls IsShared to determine if the object is sharable. Color_IsShared always returns true, indicating that all color objects are shared. See Object_IsShared for more information.