ColorManager Class Reference

The ColorManager JavaScript class. This interface is used to control the current palette active color. More...

Public Slots

ColorRGBA getCurrentColorData ()
 Get the color data of the currently active color. More...
 
BaseColor getColorDataWithIndex (int index)
 Get the color data of a color from the palette. More...
 
BaseColor getColorDataWithId (String id)
 Get the color data of a color from the palette. More...
 
int getCurrentColorH ()
 Gets the Hue of the currently active color. More...
 
int getCurrentColorS ()
 Gets the Saturation of the currently active color. More...
 
int getCurrentColorV ()
 Gets the Value of the currently active color. More...
 
int getCurrentColorOpacity ()
 Get the opacity of the currently active color. More...
 
String getColorIdFromPosition (int index)
 Gets the Id of a color from the palette. More...
 
void setCurrentColorRGBA (int r, int g, int b, int a)
 Set a RGB value to the currently active color. More...
 
void setCurrentColorHSVA (int h, int s, int v, int a)
 Set a HSV value to the currently active color. More...
 
void setCurrentColorOpacity (int a)
 Set the opacity of the currently active color. More...
 
void setActiveColor (String id)
 Select a color from the palette to be the active one. More...
 
void addCurrentColorToPalette ()
 Add a new color to the palette with the current RGBA value. More...
 
void removeCurrentColor ()
 Remove the currently selected color from the palette. More...
 
void exportColors (String path)
 Export the color palette to a .plt file. More...
 
void importColors (String path, bool importDuplicate)
 Import colors from a .plt file. More...
 
void importTexture (String path)
 Import a texture. More...
 
void saveAsDefaultPalette ()
 

Detailed Description

The ColorManager JavaScript class. This interface is used to control the current palette active color.

Note
Handle color
// Active the color at index 6 of the current color
var cm = new ColorManager();
var id = cm.getColorIdFromPosition(6);
MessageLog.trace("ColorID: "+ id)
cm.setActiveColor(id);

Member Function Documentation

◆ addCurrentColorToPalette

void ColorManager::addCurrentColorToPalette ( )
slot

Add a new color to the palette with the current RGBA value.

◆ exportColors

void ColorManager::exportColors ( String  path)
slot

Export the color palette to a .plt file.

Parameters
path- full path for the output file (Note: if the file already exists, it will be overwritten)

◆ getColorDataWithId

BaseColor ColorManager::getColorDataWithId ( String  id)
slot

Get the color data of a color from the palette.

Parameters
id- id of the color in the palette
Returns
BaseColor Color data
var cm = new ColorManager();
var color = cm.getColorDataWithId(id);
MessageLog.trace("r : " + color.colorData.r);
MessageLog.trace("g : " + color.colorData.g);
MessageLog.trace("b : " + color.colorData.b);
MessageLog.trace("a : " + color.colorData.a);

◆ getColorDataWithIndex

BaseColor ColorManager::getColorDataWithIndex ( int  index)
slot

Get the color data of a color from the palette.

Parameters
index- position of the color in the palette
Returns
BaseColor Color data
var cm = new ColorManager();
var color = cm.getColorDataWithIndex(2);
MessageLog.trace("r : " + color.colorData.r);
MessageLog.trace("g : " + color.colorData.g);
MessageLog.trace("b : " + color.colorData.b);
MessageLog.trace("a : " + color.colorData.a);

◆ getColorIdFromPosition

String ColorManager::getColorIdFromPosition ( int  index)
slot

Gets the Id of a color from the palette.

Parameters
index- the position of the color in the palette
Returns
Returns the color Id from the ColorView.

◆ getCurrentColorData

ColorRGBA ColorManager::getCurrentColorData ( )
slot

Get the color data of the currently active color.

Returns
BaseColor Color data
var cm = new ColorManager();
var color = cm.getCurrentColorData();
MessageLog.trace("r : " + color.r);
MessageLog.trace("g : " + color.g);
MessageLog.trace("b : " + color.b);
MessageLog.trace("a : " + color.a);

◆ getCurrentColorH

int ColorManager::getCurrentColorH ( )
slot

Gets the Hue of the currently active color.

Returns
the Hue (between 0 and 255)

◆ getCurrentColorOpacity

int ColorManager::getCurrentColorOpacity ( )
slot

Get the opacity of the currently active color.

Returns
The alpha (opacity) value between 0 and 255

◆ getCurrentColorS

int ColorManager::getCurrentColorS ( )
slot

Gets the Saturation of the currently active color.

Returns
the Saturation (between 0 and 100)

◆ getCurrentColorV

int ColorManager::getCurrentColorV ( )
slot

Gets the Value of the currently active color.

Returns
the Value (between 0 and 100)

◆ importColors

void ColorManager::importColors ( String  path,
bool  importDuplicate 
)
slot

Import colors from a .plt file.

Parameters
path- path to the .plt file
importDuplicate- whether or not duplicate colors will be imported

◆ importTexture

void ColorManager::importTexture ( String  path)
slot

Import a texture.

Parameters
path- path to the texture file

◆ removeCurrentColor

void ColorManager::removeCurrentColor ( )
slot

Remove the currently selected color from the palette.

◆ saveAsDefaultPalette

void ColorManager::saveAsDefaultPalette ( )
slot

◆ setActiveColor

void ColorManager::setActiveColor ( String  id)
slot

Select a color from the palette to be the active one.

Parameters
id- Id of the color

◆ setCurrentColorHSVA

void ColorManager::setCurrentColorHSVA ( int  h,
int  s,
int  v,
int  a 
)
slot

Set a HSV value to the currently active color.

Parameters
h- Hue (between 0 and 255)
s- Saturation (between 0 and 100)
v- Value (between 0 and 100)
a- Alpha (between 0 and 255)

◆ setCurrentColorOpacity

void ColorManager::setCurrentColorOpacity ( int  a)
slot

Set the opacity of the currently active color.

Parameters
a- alpha (opacity) (between 0 and 255)

◆ setCurrentColorRGBA

void ColorManager::setCurrentColorRGBA ( int  r,
int  g,
int  b,
int  a 
)
slot

Set a RGB value to the currently active color.

Parameters
r- Red channel value (between 0 and 255)
g- Green channel value (between 0 and 255)
b- Blue channel value (between 0 and 255)
a- Alpha value (between 0 and 255)