'ShiftMatrix'

  Previous  Next

The shifting function allows you to move the content of the matrix into a given direction. It is declared as follows:

void ShiftPixelMatrix(int x, int y, int w, int h, int dir, int step)
void ShiftVectorMatrix(float x, float y, float w, float h, int dir, float step) 

 

Again there are two possibilities. One is used with absolute pixel coordinates and values, and one uses relative coordinates and values between 0.0 and 1.0.

x, y, w, and h define the area that should be shifted.

step defines how wide the content should be shifted into a given direction, which is specified by dir.

For dir »the SHIFT direction values are allowed. If the value of dir is invalid, the default direction SHIFT_TOP will be used.

 

The following script for the MAS Script Effect fills the matrix with yellow and draws a red cross onto it during initialization. During the rendering of the content, the whole matrix is shifted downwards. Hence, the cross is moving to the bottom of the matrix. You can simply copy and paste it.

void InitEffect()
{
 color colbg ={255,255};
 color col ={255};
 Clear(colbg);
 DrawVectorShape(col,DRAWSHAPE_CROSS,0.0,0.0,0.0,1.0,1.0,1.0);
}
 
void RenderEffect()
{
 ShiftPixelMatrix(0,0,GetMatrixWidth(),GetMatrixHeight(),SHIFT_DOWN,1);
}
 
 
 

The script also demonstrates an important behavior of the function. As you can see, the matrix remains yellow, but the cross moves to the bottom. Furthermore, red lines will be drawn on the left and the right side. This is due to the fact that the Shift function copies the complete content of the matrix and redraws this picture on the new position. While the content is moved into the given direction, the original matrix is left unchanged. This leaves the first pixel line unchanged in our example.

 

MADRIX Version: 5.7 | Script Version: 3.23
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100%
 Previous   Next

 


Enable automatic translation | Activer la traduction automatique |