Page 1 of 1

linear() in scripting

Posted: July 6th, 2009, 6:30 am
by mads
I want to Use a function like the expression function linear() in my Script how do I do that?
-mads

Re: linear() in scripting

Posted: July 6th, 2009, 10:41 am
by mads
This could also be a more general questions

-How do I Use expression function like 'toComp()', 'fromWorld()', 'ease()', 'linear()' e.t.c. in a Script?

-Mads

Re: linear() in scripting

Posted: July 6th, 2009, 10:58 am
by mads
I try to make my own linear:

Code: Select all

function linear(input,fromMin,fromMax,tooMin,tooMax){
	input = Math.min(input,fromMax);
	input = Math.max(input,fromMin);
	var y = (((tooMax-tooMin)/(fromMax-fromMin))*(input-fromMin))+tooMin;
	return y;
}
but have to test it...

Re: linear() in scripting

Posted: August 12th, 2009, 10:34 am
by nab
There are two possibilities for using these functions:
1) write a temporary expression and retrieve the value (preExpression flag set to false). Easy to code but slow execution (ok for computing few values)
2) port these Expression functions to pure JavaScript that a script will understand. Some of them are easy to implement, some require more effort (especially the layer space transform, still doable though :wink: ). Obviously the way to go in case of many function calls.