'SetPixel'

   Print  Previous  Next

Functionality

SetPixel functions offer the possibility to change the color of pixels. You can either specify a certain color or use grayscale. The following examples use only some of the functions that are available.

 

Examples

SetPixel

To test this script, please use the MAS Script Effect.
This sample paints red pixels onto the complete matrix with different brightness values.

@scriptname="SetPixel test, use with MAS Script Effect";

@author="";

@version="";

@description="";

 

 color col;

 int maxX,maxY,x,y;

 void InitEffect()

 {

    maxX=GetMatrixWidth();

    maxY=GetMatrixHeight();

 }

 

 void RenderEffect()

 {

    col.r=random(0,255);

    x=random(0,maxX-1);

    y=random(0,maxY-1);

    SetPixel(col,x,y);

 }

 

 void MatrixSizeChanged()

 {

    InitEffect();

 } 

 

SetPixel3D

To test this script, please use the MAS Script Effect.
This sample paints golden pixels onto the complete matrix. Please use a 3D matrix.

@scriptname="SetPixel3D test, use with MAS script effect";

@author="";

@version="";

@description="";

 

 int maxX,maxY,maxZ,x,y,z;

         

 void InitEffect()

 {

    maxX=GetMatrixWidth();

    maxY=GetMatrixHeight();

    maxZ=GetMatrixDepth();

 }

 

 void RenderEffect()

 {

    Clear();

    x=random(0,maxX-1);

    y=random(0,maxY-1);

    z=random(0,maxZ-1);

    SetPixel3D(GOLD,x,y,z);

 }

 

 void MatrixSizeChanged()

 {

    InitEffect();

 }  

 

SetPixel - Filling The Matrix

To test this script, please use the MAS Script Effect.
This sample fills every pixel of every row of the matrix with the color white from left to right until the complete matrix is covered. Every second iteration black is used instead of white.

@scriptname="SetPixelSample";

@author="inoage";

@version="MADRIX 2.13";

@description="a simple setpixel example to fill the matrix";

 

int x,y,c;

color col;

 

void InitEffect()

{

   x=0;

   y=0;

   c=0;

   col=WHITE;

}

 

void RenderEffect()

{

     SetPixel(col,x,y);

  x++;

  if(x>=GetMatrixWidth())

  {

         x=0;

         y++;

         if(y>=GetMatrixHeight())

         {

                 y=0;

                 c++;

                 if(c%2==0)

                         col=WHITE;

                 else

                         col=BLACK;

         }

  }

}

 

void MatrixSizeChanged()

{

 InitEffect();

}

 

SetPixelGrayscale (MAS Script)

To test this script, please use the MAS Script effect.

@scriptname="sample of grayscale for a single pixel";

@author="";

@version="";

@description="";

 

  int X,Y;

  void InitEffect()

  {

    X=GetMatrixHeight();

    Y=GetMatrixWidth();

    Clear(BLUE);

  }

 

  void RenderEffect()

  {

    for(int i=0;i<X && i<Y;i++)

  {

    SetPixelGrayscale(i,i); // line from top left to bottom right

    SetPixelGrayscale(X-i-1,i); // line from top right to bottom left

  }

    // to render the complete matrix in grayscale, the grayscale() command 

    // offers higher performance:

    // Grayscale();

  }

 

  void MatrixSizeChanged()

  {

    InitEffect();

  }

 

SetPixelGrayscale (Macro)

To test this script, you can use the Main Output Macro.
But first, please select for example the SCE Color Scroll effect in Storage Left or Right and display the effect on the output.

@scriptname="sample of grayscale for single pixel";

@author="";

@version="";

@description="";

 

  int X,Y;

  void InitEffect()

  {

    X=GetMatrixWidth();

    Y=GetMatrixHeight();

  }

 

  void PreRenderEffect()

  {

  }

 

  void PostRenderEffect()

  {

    if(X>Y)// width larger than height

  {

  for(int i=0;i<Y;i++)

  {

    SetPixelGrayscale(i,i); // line from top left to bottom right

    SetPixelGrayscale(i,Y-i-1); // line from top right to bottom left

  }

  }

    else // height larger than width

  {

  for(int i=0;i<X;i++)

  {

    SetPixelGrayscale(i,i); // line from top left to bottom right

    SetPixelGrayscale(X-i-1,i); // line from top right to bottom left

  }

  }

    // to render the complete matrix in grayscale, the Grayscale() command 

    //  offers higher performance

    // Grayscale();

  } 

 

MADRIX Version: 3.6j | Script Version: 2.22
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100%
Print   Previous   Next