Using Color Table

   Print  Previous  Next

Functions Provided For Using The Color Table

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

Color Table Feature

Color Table

 

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()

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 0, the new color is added to the first position. If the index is equal to or 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 fade)

Use 1 (TRUE) to activate the color Fade mode. Use 0 (FALSE) to deactivate it.

int ColorTableGetColorFade()

Returns 1 (TRUE) if the color Fade mode is activated, otherwise 0 (FALSE).

void ColorTableToggleColorFade()

Toggles the color Fade mode.

void ColorTableSetColorMode(int mode)

Sets the Color Mode. Please use a constant as described below for mode.

int ColorTableGetColorMode()

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 be 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 another 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.

 

Example

This example ensures the amount of 6 colors in the Color Table and sets this 6 colors to defined values. The color fade and the loop mode 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

 ColorTableSetColorFade(true);        

 

 //set loop mode

 ColorTableSetColorMode(COLOR_MODE_LOOP);

 

}

 

void PreRenderEffect()

{

}

 

void PostRenderEffect()

{

}

 

void MatrixSizeChanged()

{

 InitEffect();

}

 

MADRIX Version: 5.1b | Script Version: 3.10
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100%
Print   Previous   Next