|
Functions Provided For Using The Color Table
Some effects provide more than one color. In this case the so-called Color Table (described here), »Using Color Gradient, »Using Color Gradient Dialog or »Using M2L Color Table is offered by the effect to take control of the colors.


The following table provides an overview of all functions the effect can use to modify the colors in a Color Table:
Function
|
Description
|
void ColorTableSetColor(int index, color c)
|
Sets the color with the specified index to the given color value. If the index is out of range, nothing happens.
|
color ColorTableGetColor(int index)
|
Returns the color with the specified index in the Color Table. If the index is out of range, black is returned.
|
int ColorTableGetColorCount()
|
Returns the current number of colors in the Color Table.
|
void ColorTableInvert(void)
|
Inverts the complete Color Table regarding the positions of the colors in the table.
|
void ColorTableSwapColors(int index1, int index2)
|
Swaps colors with their specified indices in the Color Table.
|
void ColorTableAddColor(int index, color c)
|
Adds another color to the Color Table at the specified index position. If the index is lower or equal to 0, the new color is added to the first position. If the index is greater than the current number of colors, the new color is added at the end.
|
void ColorTableRemoveColor(int index)
|
Removes the color at the specified index. If the given index is out of range, nothing happens.
|
void ColorTableSetColorFade(int)
|
Use TRUE to activate the color Fade mode. Use FALSE to deactivate it.
|
int ColorTableGetColorFade(void)
|
Returns TRUE, if the color Fade mode is activated, otherwise FALSE.
|
void ColorTableToggleColorFade(void)
|
Toggles the color Fade mode.
|
void ColorTableSetColorMode(int mode)
|
Sets the Color Mode. Please use a constant as described below for mode.
|
int ColorTableGetColorMode(void)
|
Returns the current Color Mode.
|
| ▪ | For a detailed description of the non-primitive data type color, see »Using Data Types |
Remarks
Not every function might be available for each MADRIX Effect. Also, some MADRIX effects require at least 2 entries in the Color Table. You will not able to overwrite this requirement with a Macro. In some MADRIX effects you cannot add or delete the number of colors, only the colors itself.
Color Mode Constants
Constant
|
Description
|
int COLOR_MODE_LOOP
|
The colors of the list will be used one after each other in a loop.
|
int COLOR_MODE_SHUFFLE
|
The colors of the list will be used without a specific order.
|
int COLOR_MODE_RANDOM
|
The effect creates random colors.
|
MADRIX 2.X To MADRIX 3.X Migration Hints
The following functions are not supported anymore. Please follow the hints to migrate your macros.
Function
|
Description
|
void SetColor(int idx, color c)
|
Use ColorTableSetColor(int idx, color c) instead.
|
color GetColor(int idx)
|
Use ColorTableGetColor(int idx) instead.
|
int GetColorCount()
|
Use ColorTableGetColorCount() instead.
|
void AddColor(int idx, color c)
|
Use ColorTableAddColor(int idx, color c) instead
|
void RemoveColor(int idx)
|
Use ColorTableRemoveColor(int idx) instead.
|
void SetColorMode(int value)
|
Use ColorTableSetColorMode(int value) instead.
|
int GetColorMode()
|
Use ColorTableGetColorMode() instead.
|
Example
This example ensures the amount of 6 colors in the Color Table and sets this 6 colors to defined values. The color Fade mode and the COLOR_MODE_LOOP are set. This example works with the »SCE Color Change or »SCE Color Scroll effect, for example.
@scriptname="";
@author="";
@version="";
@description="";
//Colors
color c1 = {255,0,0}; //red
color c2 = {0,255,0}; //green
color c3 = {0,0,255}; //blue
void InitEffect()
{
//remove all colors from list until the amount of colors is 6
while(ColorTableGetColorCount() > 6)
ColorTableRemoveColor(0);
//add colors to list until the amount of colors is 6
while(ColorTableGetColorCount() < 6)
ColorTableAddColor(0,WHITE);
//set colors
ColorTableSetColor(0,c1);
ColorTableSetColor(1,c2);
ColorTableSetColor(2,c3);
ColorTableSetColor(3,YELLOW);
ColorTableSetColor(4,ORANGE);
ColorTableSetColor(5,PINK);
//activate color fade mode
ColorTableSetColorFade(true);
//set color mode to COLOR_MODE_LOOP
ColorTableSetColorMode(COLOR_MODE_LOOP);
}
void PreRenderEffect()
{
}
void PostRenderEffect()
{
}
void MatrixSizeChanged()
{
InitEffect();
}
|