| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (15 out of 18)

Specifying an Icon Background Layer

G2 provides an optional icon layer called the icon-background-layer, which appears behind all other components of an icon. This layer can contain a monochrome or polychrome image, or can be of any G2 color. Unlike imported images in other layers, a polychrome image in an icon background layer appears in polychrome on the screen.

An image in a background layer is called a background image, and the color of a colored background layer is called the background color. An icon background layer cannot simultaneously have both an background image and a background color.

Specifying a Background Image

To specify an icon background image for a class:

  1. Use the Text Editor to give the class definition's icon description an icon-background-layer section.

  2. Specify the name and location of the image using the grammar:

    where image-name is the name of an image-definition, and x-position and y-position give the position of the upper left corner of the image relative to the upper left corner of the icon.

For example, if corporate-logo is an image, the definition:

displays the image in the background layer at the indicated coordinates.

Notes on Background Images

When you use the Icon Editor to edit an icon that includes a background image, the image appears in the Icon Viewer, but cannot be edited: it appears only to facilitate designing the rest of the icon.

If a background image is larger than the icon that displays it, G2 clips it to fit the available area, both in the Icon Viewer and on a workspace.

If you specify a background image that does not exist, G2 puts a warning in the class definition's Notes attribute, but does not signal an error. The icon looks just as it would if the unresolved definition did not exist.

A background image definition applies to all instances of a class: you cannot change background images per-instance.

Various GIFs that can be used as icon background images are available in the G2 demos directory, as described under GIF Files.

Specifying a Background Color

A background color can be specified explicitly or by naming a region, in which case the background layer has the color of that region. When a region gives the background color, the color can be changed programmatically. A background color completely fills the background of an icon, irrespective of the icon's size.

To specify an icon background color for a class:

  1. Use the Text Editor to give the class definition's icon description an Icon-background-layer section.

  2. Specify the value of the layer to be either:

For example:

or:

where my-region is any defined region.

To change the icon background color of an instance:

  1. Specify the icon background color in the class icon description by giving a region-name rather than a specific color.

  2. Execute:

    where:

For example:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (15 out of 18)

Copyright © 1997 Gensym Corporation, Inc.