Skip to content

FxColorPalette ​

This module contains functions for editing the items of a Color Palette. Each color palette has 256 items - or colors - which can be refered to by an ItemIndex. All functions of this module work on the open color palette. To open a color palette use FxFile.Open. An item can only be edited if it is available. To make a new item available use CreateItem. To save the changes made after editing the open color palette use FxFile.Save.

Load ​

lua
FxColorPalette = require "FxColorPalette";

Functions ​

FunctionDescription
Clear ()Deletes all items.
CreateItem ()Creates a new item.
DeleteItem (ItemIndex)Deletes an item.
GetItemColor (ItemIndex)Returns the color of an item.
GetItemName (ItemIndex)Returns the name of an item.
SetItemColor (ItemIndex, Value)Sets the color of an item.
SetItemName (ItemIndex, Value)Sets the name of an item.

Clear () ​

This function deletes all items from the open color palette.

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxColorPalette.Clear();

CreateItem () ​

This function creates an item, adds it to the opened color palette, initializes it with default values and returns its index.

Returns ​

The ItemIndex of the new item.

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_FILE_OPERATION_FAILED

Since ​

Version 1.0

Example ​

lua
itemindex = FxColorPalette.Create();

DeleteItem (ItemIndex) ​

This function deletes the specified item, making it unavailable.

Parameters ​

  • ItemIndex: The ItemIndex of the item to be deleted

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_ITEM_INDEX_INVALID, FX_ITEM_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxColorPalette.DeleteItem(20);

GetItemColor (ItemIndex) ​

This function returns the color of the specified item.

Parameters ​

  • ItemIndex: The ItemIndex of the item to query

Returns ​

Color

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_ITEM_INDEX_INVALID, FX_ITEM_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
-- get color of item 2
color = FxColorPalette.GetItemColor(2);

GetItemName (ItemIndex) ​

This function returns the name of the specified item.

Parameters ​

  • ItemIndex: The ItemIndex of the item to query

Returns ​

Name

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_ITEM_INDEX_INVALID, FX_ITEM_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
name = FxColorPalette.GetItemName(2);

SetItemColor (ItemIndex, Value) ​

This function sets the color of the specified item.

Parameters ​

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_ITEM_INDEX_INVALID, FX_ITEM_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
color = FxColor.CreateFromHex("#ff00ff");
FxColorPalette.SetItemColor(10, color);

SetItemName (ItemIndex, Value) ​

This function sets the name of the specified item.

Parameters ​

ItemIndex: The ItemIndex of the item Value: The new name

Errors ​

Possible errors include FX_REQUIRED_FILE_UNAVAILABLE, FX_ITEM_INDEX_INVALID, FX_ITEM_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxColorPalette.SetItemName(10, "Fuchsia");