Name
CreatePalette -- create new palette (V9.0)
Synopsis
[id] = CreatePalette(id[, data, t])
Function
This function creates a new palette and assigns the identifier id to it. The data argument may either be a table containing a number of colors that should be used to initialize the palette's pens or you may set data to one of Hollywood's predefined palette types. See below for all predefined palette types supported by Hollywood. If you pass Nil in the id argument, CreatePalette() will automatically choose an identifier for the new palette and return it to you.

The following predefined palette types are supported by Hollywood:

#PALETTE_MONOCHROME:
Two color, black and white palette.

#PALETTE_GRAY4:
4 color grayscale palette.

#PALETTE_GRAY8:
8 color grayscale palette.

#PALETTE_GRAY16:
16 color grayscale palette.

#PALETTE_GRAY32:
32 color grayscale palette.

#PALETTE_GRAY64:
64 color grayscale palette.

#PALETTE_GRAY128:
128 color grayscale palette.

#PALETTE_GRAY256:
256 color grayscale palette.

#PALETTE_CGA:
Standard CGA palette (16 colors).

#PALETTE_OCS:
Standard OCS palette (32 colors).

#PALETTE_EGA:
Standard EGA palette (64 colors).

#PALETTE_AGA:
Standard AGA palette (256 colors).

#PALETTE_WORKBENCH:
Standard classic Amiga Workbench palette (256 colors).

#PALETTE_MACINTOSH:
Standard classic Macintosh palette (256 colors).

#PALETTE_WINDOWS:
Standard classic Windows palette (256 colors).

#PALETTE_DEFAULT:
Same as #PALETTE_AGA. If you omit the data argument, CreatePalette() will initialize the new palette using the pens from #PALETTE_DEFAULT.

If you pass a table of colors in the data argument, make sure that all colors are passed as RGB values. Note that the table can also be a sparse array with only the pens initialized that you actually need. Pens that aren't in the data table will be initialized to black. See below for an example.

The optional table argument t can be used to specify further options. The following options are currently recognized:

Depth:
The desired depth for the palette. This must be between 1 (= 2 colors) and 8 (= 256 colors). The default is 8. If Depth specifies more colors than you pass in the table in the data parameter, the remaining colors will be initialized to black. This tag is only used if you pass a table in the data argument. If you pass a predefined palette type in data, the predefined palette type's depth overrides the depth specified here.

TransparentPen:
This tag can be used to specify the pen that shall be transparent in the palette. This defaults to #NOPEN which means that no pen shall be made transparent.

Cycle:
This tag can be used to define several ranges of colors that can be cycled. When set, you must pass a table of subtables to Cycle, each subtable describing a configuration of a color cycling effect. Each subtable supports the following tags:

Low:
The pen index that marks that start of the color range.

High:
The pen index that marks the end of the color range.

Rate:
The desired speed of the color cycling effect. A value of 16384 indicates 60 frames per second. All other speeds scale linearly from this base, e.g. a value of 8192 indicates 30 frames per second, and so on.

Reverse:
If this tag is set to True, the colors should be cycled in reverse. Defaults to False.

Active:
If this tag is set to False, the color range will be marked as inactive. Defaults to True.

Inputs
id
id for the new palette or Nil for auto id selection
data
optional: either one of the predefined palette types (see above) or a table containing an array of colors (defaults to #PALETTE_DEFAULT)
t
optional: table for specifying further options (see above)
Results
id
optional: identifier of the palette; will only be returned if you pass Nil as argument 1 (see above)
Example
CreatePalette(1, {#RED, #GREEN, #BLUE}, {Depth = 2})
The code above creates a palette with four colors initialized to red, green, blue and black.


CreatePalette(1, {[0] = #RED, [127] = #BLUE, [255] = #GREEN})
The code above creates a new palette with 256 colors and initializes pen 0 to red, pen 127 to blue, and the last pen to green. All other pens will be initialized to black.


CreatePalette(1)
Creates a new palette and initializes its colors to those of #PALETTE_DEFAULT.


CreatePalette(1, #PALETTE_CGA)
Creates a new palette using the CGA colors.

Show TOC