| linear expression
• | | | |
 | linear expression
by Andrew Falk on May 21, 2012 at 11:38:43 pm |
so i am trying to animate as a test first, a simple square moving from right to left. as it approaches the center of the comp it scales up, as it continues to move past center it will scale back down.
I have posted the code i am trying to use
what am i doing wrong here?
any and all help is appreciated :)
x=transform.position[0];
scaleInStart=thisComp.layer("CONTROLLER").effect("SI")("Slider");
scaleInStop=thisComp.layer("CONTROLLER").effect("SU")("Slider");
scaleOutStart=thisComp.layer("CONTROLLER").effect("SO")("Slider");
scaleOutStop=thisComp.layer("CONTROLLER").effect("SD")("Slider");
scaleUP = linear(x,100,200,scaleInStart,scaleInStop);
scaleDown = linear(x,100,200,scaleOutStart,scaleOutStop);
linear(x,100,200,scaleUp,scaleDown);
| | | | |
• | | | |  | Re: linear expression by Dan Ebberts on May 22, 2012 at 12:13:55 am |
I haven't tested this, but I would replace the last three lines with this (it assumes that 200 is your center x position):
if (x < 200)
linear(x,100,200,scaleInStart,scaleInStop)
else
linear(x,200,300,scaleOutStart,scaleOutStop);
Dan
| | | | |
• | | | |  | Re: linear expression by Andrew Falk on May 22, 2012 at 12:26:54 am |
I will try that tonight, thanks. I had a feeling i needed an (if-else) statement in there, but wasnt sure.
Thanks, Ill let you know if it works.
| | | | |
• | | | |  | Re: linear expression by Andrew Falk on May 22, 2012 at 12:28:48 am |
i assume i could use the same thing for a rotation as well?
| | | | |
• | | | |  | Re: linear expression by Dan Ebberts on May 22, 2012 at 12:32:35 am |
The same idea should work for rotation.
Dan
| | | | |
• | | | |  | Re: linear expression by Andrew Falk on May 22, 2012 at 4:19:15 pm |
That doesnt seem to work. i get the "expression result must be of dimension 2, not 1"
| | | | |
• | | | |  | Re: linear expression by Dan Ebberts on May 22, 2012 at 4:26:52 pm |
Ah yes, sorry. For scale it would be like this:
if (x < 200)
linear(x,100,200,[scaleInStart,scaleInStart],[scaleInStop,scaleInStop])
else
linear(x,200,300,[scaleOutStart,scaleOutStart],[scaleOutStop,scaleOutStop]);
The other form should work for single-dimension properties like rotation.
Dan
| | | | |
• | | | |  | Re: linear expression by Andrew Falk on May 22, 2012 at 4:31:08 pm |
whoo, hoooo that worked. Me and a colleague were looking at the code, when your reply came through.
Thanks alot Dan!!!
| | | | |
• | | | |  | Re: linear expression by Andrew Falk on May 22, 2012 at 4:59:28 pm |
one last question, if i wanted to ease the animation, do i replace "linear" with "ease"?
| | | | |
• | | | |  | Re: linear expression by Dan Ebberts on May 22, 2012 at 5:19:20 pm |
That's correct.
Dan
| | | | |
| |
|