# Palette (Kernel)

> Palette lets you perform palette cycling animations, set the intensity of color ranges, and more. The various subfunctions will be described separately.

> Important

> SCI1.1 only.

`Palette`(palSET_INTENSITY startIndex endIndex intensity [setPalette])

  Sets the intensity of the range of colors.

  Parameters: | startIndex (number) – The inclusive starting index. endIndex (number) – The exclusive ending index. intensity (number) – Value from 0 to 100 representing the intensity. setPalette (boolean) – If TRUE, actually changes the palette value.

`Palette`(palANIMATE startIndex endIndex speed)

  “Animates” the palette colors in a particular direction. This allows for palette cycling effects.

  Parameters: | startIndex (number) – The inclusive starting index. endIndex (number) – The exclusive ending index. speed (number) – A speed (lower numbers are faster) and direction (negative or positive).

  A single call to Palette(palANIMATE ...) will only shift the palette by one. It needs to be called repeatedly in a Script’s doit() method to keep cycling the colors.

  Example:

      (method (doit)
              (super doit:)
              (Palette palANIMATE 192 198 -9)
      )

`Palette`(palSET_FROM_RESOURCE resourceNumber [force])

  Sets the current palette from a palette resource.

  Parameters: | resourceNumber (number) – The palette resource number. force (nunber) – If force is 2, the palette set is forced.

  Example:

      (Palette palSET_FROM_RESOURCE 999 2)

`Palette`(palSET_FLAG startIndex endIndex flag)

`Palette`(palUNSET_FLAG startIndex endIndex flag)

  Sets or unsets a flag for a palette index.

  Parameters: | startIndex (number) – The inclusive starting index. endIndex (number) – The exclusive ending index. flag (number) – A flag. 1 indicates this palette color is used. 0 indicates it is not.

`Palette`(palFIND_COLOR red green blue)

  Finds the closest palette index to a particular color.

  Parameters: | red (number) – The red component (0-255) green (number) – The green component (0-255) blue (number) – The blue component (0-255)
  Returns: | The index of the color most closely matching the given RGB color.

  Example:

      (= gLowlightColor (Palette palFIND_COLOR 159 159 159))

`Palette`(palSAVE)

  Saves the current palette to be restored later.

  Returns: | A cookie to use for restoring.

`Palette`(palRESTORE cookie)

  Restores a palette.

  Parameters: | cookie (number) – A cookie returned from Palette(palSAVE).