linear() in scripting

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
mads
Posts: 33
Joined: October 15th, 2004, 6:38 am
Location: Denmark
Contact:

I want to Use a function like the expression function linear() in my Script how do I do that?
-mads
mads
Posts: 33
Joined: October 15th, 2004, 6:38 am
Location: Denmark
Contact:

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
mads
Posts: 33
Joined: October 15th, 2004, 6:38 am
Location: Denmark
Contact:

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...
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

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.
Post Reply