open-palette

Generic Function

Package: common-graphics

Arguments: device-or-stream rgb-vector &optional animated-entries

Creates and returns a palette and returns a handle to that palette (i.e. an integer) that is appropriate to assign to device-or-stream. Generally this palette will be compatible with all windows, and (screen*system*) may be used for this argument.

rgb-vector should be a vector of up to 256 rgb colors. For example, the following form returns a vector of six colors using predefined colors (cyan, red, black, and white) and new colors created with make-rgb:

(setq cv (vector cyan (make-rgb :blue 10 :yellow 33) 
                 red (make-rgb :green 154 :red 0 :blue 99)
                 black white))

animated-entries should be a list of indices of rgb-vector which are candidates for animation. See animate-color-number. The OS is instructed not to share these colors.

With cv as defined just above, create a suitable palette for (screen*system*) with

(setq my-palette (open-palette (screen *system*) cv))

Note that this function does not assign the returned palette to device-or-stream. That must be done with setf palette.

Warning: the palette handle returned by this function is an address. This address will be valid so long as the current invocation of Lisp is running but may not be valid if the image is dumped (with dumplisp) and rerun (it may be valid if rerun on the same machine, it is less likely to be valid on a different machine running the same operating system, it is very unlikely to be valid on a different machine running a different operating system). Therefore, palettes should be initialized each time Allegro CL (or an Allegro CL application) is run.

Note: incompatible change in release 6.0: in releases prior to 6.0, when a frame-with-single-child instance was passed to this operator, the operator was actually applied to the child (the result of applying frame-child to the frame-with-single-child instance). In release 6.0, this redirection no longer occurs. If you intend this operator to apply to the frame-child, pass that to this operator rather than the parent. This is a non-backward-compatible-change. See the release notes for more information.

For information on when palettes are useful (or necessary) see About color palettes in cgide.htm.

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.