I want to Use a function like the expression function linear() in my Script how do I do that?
-mads
linear() in scripting
Moderator: Paul Tuersley
Mads Juul
http://madsjuul.blogspot.com/
http://madsjuul.blogspot.com/
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
-How do I Use expression function like 'toComp()', 'fromWorld()', 'ease()', 'linear()' e.t.c. in a Script?
-Mads
Mads Juul
http://madsjuul.blogspot.com/
http://madsjuul.blogspot.com/
I try to make my own linear:
but have to test it...
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;
}
Mads Juul
http://madsjuul.blogspot.com/
http://madsjuul.blogspot.com/
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
). Obviously the way to go in case of many function calls.
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
