SetPalette(id[, t])
id
. By default, the current display's palette is the active palette but of course only in case
the current display is a palette mode display. See Palette mode displays for details.
A palette can be made the active one by using the SelectPalette() command.
Alternatively, the palette specified by id
can also be copied to other objects.
To do so, you need to pass the optional table argument to SetPalette()
and set the
destination object type in the Type
table tag and the object's identifier in the
ID
table tag. For example, to assign palette 1 to brush 2, do the following:
SetPalette(1, {Type = #BRUSH, ID = 2}) |
The following tags are supported by the optional table argument t
:
Type:
#ANIM #BGPIC #BRUSH #DISPLAY #LAYER #PALETTE #SPRITE |
Note that if you use types #ANIM
or #SPRITE
, you also need to set the Frame
tag (see below) to indicate the frame whose palette you want to modify. If
you use #LAYER
and the specified layer is an anim layer, you also need to
set the Frame
tag.
Type
defaults to the type of the currently active palette selected using
SelectPalette(). See SelectPalette for details.
ID:
Frame:
Remap:
True
, the colors of the target object will be remapped to
match the colors in the source palette as closely as possible. By default,
there will be no remapping and the actual pixel data of the target object
will remain untouched. If you want remapping, set this tag to True
but
be warned that remapping all pixels will of course take much more time than
just setting a new palette without remapping. Defaults to False
.
Dither:
Remap
tag (see above) has been set to True
, you can use the Dither
tag to specify whether or not dithering should be used. Defaults to True
which
means dithering should be used.
CopyCycleTable:
True
, this cycle table will be copied to the target object as well.
Defaults to False
.
@DISPLAY {Palette = #PALETTE_MONOCHROME} SetFillStyle(#FILLCOLOR) SetPaletteMode(#PALETTEMODE_PEN) SetDrawPen(1) Box(#CENTER, #CENTER, 320, 240) WaitLeftMouse CreatePalette(1, {#WHITE, #BLACK}, {Depth = 1}) SetPalette(1)The code above creates a monochrome palette display with a black background and white rectangle in the center. After a mouse-click the colors of the background and the white rectangle will be reversed by setting a new palette which uses white instead of black in pen 0 and black instead of white in pen 1.