MADRIX Forum • New to madrix programming...
Page 1 of 1

New to madrix programming...

Posted: Mon Jul 14, 2014 10:34 pm
by downwithden
Hello, I was wondering if there is a way to change the size of a certain shape with the code provided in the madrix script manual. Below is the sample of your code. Any help would be appreciated, thank you.

Code: Select all

@scriptname="";
@author="";
@version="";
@description="";
 
int g_startTime;
int g_run;
 
void InitEffect()
{
 time t = GetTime();
 g_startTime = t.hour * 3600 + t.min * 60 + t.sec;
 
 g_run = 0;
}
 
void PreRenderEffect()
{
 time t = GetTime();
 int t2 = t.hour * 3600 + t.min * 60 + t.sec;
 
 if(t2 - g_startTime >= 1)
 {
         g_startTime = t2;
         switch(g_run % 6)
         {
         case 0:        SetShapeType(SHAPE_TYPE_CIRCLE_OUTLINED_EXPLODE);        break;
         case 1:        SetShapeType(SHAPE_TYPE_CIRCLE_OUTLINED);                        break;
         case 2:        SetShapeType(SHAPE_TYPE_CIRCLE_OUTLINED_IMPLODE);        break;
         case 3:        SetShapeType(SHAPE_TYPE_SQUARE_OUTLINED_EXPLODE);        break;
         case 4:        SetShapeType(SHAPE_TYPE_SQUARE_OUTLINED);                        break;
         case 5:        SetShapeType(SHAPE_TYPE_SQUARE_OUTLINED_IMPLODE);        break;
         default:        break;
         }
         g_run++;
 }
}
 
void PostRenderEffect()
{
 
}
 
void MatrixSizeChanged()
{
    InitEffect();
}

Re: New to madrix programming...

Posted: Tue Jul 15, 2014 9:23 am
by Guertler
Hello downwithden,
.
Please have a look to the code below.
The code was conformed and now the size of the shapes will be automatically increased respectively decreased.
.
If you have any further questions, please do not hesitate to contact us again!
Thank you.

Code: Select all

@scriptname="";
@author="";
@version="";
@description="";

int g_startTime;
int g_run;

int sizeUp = 1;			//if the value is 1 the size will increase, if the value is 0 the size                               // will decrease

void InitEffect()
{
	time t = GetTime();
	g_startTime = t.hour * 3600 + t.min * 60 + t.sec;

	g_run = 0;
}

void PreRenderEffect()
{
	time t = GetTime();
	int t2 = t.hour * 3600 + t.min * 60 + t.sec;

	if (t2 - g_startTime >= 1)
	{
         g_startTime = t2;
     
     	if (GetSize()<= 10.0)				// if the actual size of the shapes is less or equals 10 
     		sizeUp = 1;                   //we want to increase the size of the shapes

     	if (GetSize() >= 100.0)			// if the actual size of the shapes is grater or equals 10 
     		sizeUp = 0;                   //we want to decrease the size of the shapes
   
   		if (sizeUp == 1)				// if sizeUp is 1 the shape size will be increased
   			SetSize(GetSize() + 1.0);
   		else
   			SetSize(GetSize() - 1.0);  		// else (sizeUp = 0) the shape size will decreased
	}
}

void PostRenderEffect()
{

}

void MatrixSizeChanged()
{
	InitEffect();
}



Re: New to madrix programming...

Posted: Tue Jul 15, 2014 9:53 pm
by downwithden
Let's say I wanted to start from scratch, and i wanted to create my own shapes. Is that possible?

Also, is there a difference between prerender, render, and postrender effects? What exactly are each of those used for?

Re: New to madrix programming...

Posted: Wed Jul 16, 2014 9:57 am
by Guertler
Hello downwithden,
.
When you will use a macro to confirm a effect you will be able to use the macro functions which are listed in the "Scripting Help and Manual" for each effect.
http://help.madrix.com/m3/html/script/index.html
That means you will not be able to create an own shape, you can only choose a desired shape from the list.
.
When you will create an own effect for example with own shapes you have to create a "MADRIX Script" effect.
Here you can find some more information about the "Script" effect
http://help.madrix.com/m3/html/script/i ... rview.html
.
Now regarding to your question about the difference default generated functions of the Macro respectively Script Editor.
If you want to compile a macro the editor must have at least the functions: InitEffect(), PreRenderEffect() and PostRenderEffect().
If you want to compile a script the editor must have at least the function InitEffect() and RenderEffect().
.
InitEffect(): The expressions which are located in this function will only processed once at the start of the script or macro.
.
PreRenderEffect(): You will find this function only in the Macro editor. The expressions and calculations which are located in this function will be calculated everytime before the desired effect will be rendered.
You have to know MADRIX renders the effects with 50 FPS.
.
PosRenderEffect(): You will find this function only in the Macro editor. The expressions and calculations which are located in this function will be calculated everytime after the desired effect will be rendered.
.
RenderEffect(): This function you will find in the Script editor. The expressions and calculations which are located in this function will be calculated everytime when the script effect will be rendered.
.
MatrixSizeChanged(): The expressions and calculations of this function will only calculated when the size of the matrix / the patch was changed.
.
If you have any further questions, please do not hesitate to contact us again!
Thank you.