Using Colors

   Print  Previous  Next

Basically, there are three different possibilities an effect allows to choose a color.

Color Picker/FaderBox

Color PickerFaderBox

Some simpler effects, such as SCE Color or SCE Pulse/ Stroboscope, only support one particular color at a time. Then, make use of the following functions:

Function

Description

void SetColor(color col)

Sets the color for the effect.

color GetColor()

Returns the currently set color.

Please note: Some effects may have deviant functions, such as SetFilterColor or SetTextColor.

 

Example

Insert the following example into the Effect Macro Editor of the SCE Color effect.

@scriptname="Color Picker Example";

@author="";

@version="";

@description="";

 

 

 color c = {111,111,111};

 

void InitEffect()

{

 

}

 

void PreRenderEffect()

{

 SetColor(c);

}

 

void PostRenderEffect()

{

 color g = GetColor();

 WriteText("Red: "+(string)g.r+", Green: "+(string)g.g+", Blue: "+(string)g.b);

}

 

 

Color Ramp (Control)

Color Ramp

The Color Ramp appears in effects, like SCE Color Ramp, SCE Plasma, or S2L Waveform. Use the following functions to set the colors:
Please note: Not all effects may support all functions.

Function

Description

void SetColor(int index, color c)

Sets the color c at the specified index in the Color Ramp. If index is out of range, nothing happens.

color GetColor(int index)

Returns the color with the specified index in the Color Ramp. If the index is out of range, black is returned.

int GetColorCount()

Returns the amount of colors currently used by the Color Ramp.

void AddColor(color c, float position, int fade)

Adds another color c to the Color Ramp at the specified position. Valid values for position range from 0.01 to 0.99. If the index is lower or equal to 0, the new color is added to the first position. If index is greater than the current number of colors, the new color is added at the end. Valid values for fade are 1 (On) or 0 (Off).

void RemoveColor(int index)

Removes the color at the specified index. If the given index is out of range, nothing happens.

int SetColorPosition(int index, float position)

Sets the color of the given index to a new position and returns the new index. Valid values for position range from 0.01 to 0.99. The first and last color are not allowed to be moved!

float GetColorPosition(int index)

Returns the color position of the given index.

void SetColorFade(int index, fade)

Sets the color fade option for the given index. Valid values for fade are 1 (On) or 0 (Off).

int GetColorFade(int index)

Returns the color fade option for the given index.

void FadeAllColors()

Enables color fade for all colors in the Color Ramp.

void FadeNoneColors()

Disables color fade for all colors in the Color Ramp.

void SetUniformDistances()

Sets uniform distances between each color in the Color Ramp.

void InvertColorPositions()

Inverts the positions of the colors in the Color Ramp.

void InvertColors()

Inverts every single color in the Color Ramp.

 

Example

Insert the following example into the Effect Macro Editor of the SCE Color Ramp effect.

@scriptname="";

@author="";

@version="";

@description="";

 

 color c = {222,222,222};

 

void InitEffect()

{

 

}

 

void PreRenderEffect()

{

         SetColor(2,c);

 int n = GetColorCount();

 WriteText((string)n);

            

}

 

void PostRenderEffect()

{

 color g = GetColor(2);   //the color index starts with 0

 WriteText("Red: "+(string)g.r+", Green: "+(string)g.g+", Blue: "+(string)g.b);

}

 

 

Color Ramp (Dialog)

Color Ramp Dialog

The Color Ramp Dialog appears in effects, like SCE Fire, S2L Equalizer, and S2L Level Meter. Use the following functions to set the colors:
Please note: Not all effects may support all functions.

Function

Description

void SetColor(int index, color c)

Sets the color c at the specified index in the Color Ramp. If index is out of range, nothing happens.

color GetColor(int index)

Returns the color with the specified index in the Color Ramp. If the index is out of range, black is returned.

int GetColorCount()

Returns the amount of colors currently used by the Color Ramp.

void AddColor(color c, float position, int fade)

Adds another color c to the Color Ramp at the specified position. Valid values for position range from 0.01 to 0.99. If the index is lower or equal to 0, the new color is added to the first position. If index is greater than the current number of colors, the new color is added at the end. Valid values for fade are 1 (On) or 0 (Off).

void RemoveColor(int index)

Removes the color at the specified index. If the given index is out of range, nothing happens.

int SetColorPosition(int index, float position)

Sets the color of the given index to a new position and returns the new index. Valid values for position range from 0.01 to 0.99. The first and last color are not allowed to be moved!

float GetColorPosition(int index)

Returns the color position of the given index.

void SetColorFade(int index, fade)

Sets the color fade option for the given index. Valid values for fade are 1 (On) or 0 (Off).

int GetColorFade(int index)

Returns the color fade option for the given index.

void FadeAllColors()

Enables color fade for all colors in the Color Ramp.

void FadeNoneColors()

Disables color fade for all colors in the Color Ramp.

void SetUniformDistances()

Sets uniform distances between each color in the Color Ramp.

void InvertColorPositions()

Inverts the positions of the colors in the Color Ramp.

void InvertColors()

Inverts every single color in the Color Ramp.

 

 

Example

Insert the following example into the Effect Macro Editor of the S2L Equalizer effect and monitor the Color Ramp dialog.

@author="jky";  

@version="1.0";  

@description="change second color from colorramp";  

float pos;  

  

void InitEffect()  

{  

     pos=0.0;  

}  

  

void PreRenderEffect()  

{  

     if(GetColorCount()>2)  

     {  

          pos+=0.01;  

          pos=fmod(pos,1.0);  

         SetColorPosition(1,pos);  

     }  

}  

  

void PostRenderEffect()  

{}

 

 

Color Table

Color Table

SCE Bounce and SCE Shapes are two exemplary effects that use the so-called Color Table. Use the following functions to set the colors:

Function

Description

void SetColor(int idx, color c)

Sets the color with the specified index to the given color value. If the index is out of range, nothing happens.

color GetColor(int idx)

Returns the color with the specified index in the color table. If the index is out of range, black is returned.

int GetColorCount()

Returns the current number of colors in the color table.

void AddColor(int idx, 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 RemoveColor(int idx)

Removes the color at the specified index. If the given index is out of range, nothing happens.

Please note: 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 script. The S2L Level Ring effect always includes 3 entries. You cannot add or delete the number of colors, only the colors itself.
 

Example

Insert the following example into the Effect Macro Editor of the SCE Bounce effect.

@scriptname="";

@author="";

@version="";

@description="";

 

 color c1 = {255,255,255};

 color c2 = {255,0,0};

 

void InitEffect()

{

 AddColor(2,c2);

 RemoveColor(3);

}

 

void PreRenderEffect()

{

 SetColor(2,c1);

 int n = GetColorCount();

 WriteText((string)n);

                  

}

 

void PostRenderEffect()

 color g = GetColor(2);   //retrieving color 3, the color index starts with 0

 WriteText("Red: "+(string)g.r+", Green: "+(string)g.g+", Blue: "+(string)g.b);

}