Name
GetPen -- get pen color (V9.0)
Synopsis
color = GetPen(pen[, t])
Function
This function gets the color of the pen specified by pen from the currently active palette. 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, you can also use GetPen() to get the pen color from a different palette object. To do so, you need to pass the optional table argument t to SetPen() and specify the Type and ID tags. See below for an example.

The following tags are supported by the optional table argument t:

Type:
Set this to the type identifier of the object whose palette you want to query. This can be one of the following object types:

 
#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 query. 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:
Set this tag to the identifier of the object whose palette you want to query. The default is the identifier of the currently active palette selected using SelectPalette(). See SelectPalette for details.

Frame:
If the target type is an animation, sprite, or anim layer, you need to set this tag to specify the frame whose palette you want to query. Frames are counted from 1. Defaults to 1 when used with anims and sprites and to the current frame when used with anim layers.

Inputs
pen
pen you want to get (starting from 0)
t
optional: table for specifying further options (see above)
Results
color
color of the pen, specified as an RGB color
Example
@DISPLAY {Palette = #PALETTE_MONOCHROME}
color0 = GetPen(0)
color1 = GetPen(1)
The code above creates a monochrome palette display and queries the colors of the first two pens. color0 will be black and color1 will be white.


color = GetPen(4, {Type = #BRUSH, ID = 2})
The code gets the color of pen 4 in brush 2.

Show TOC