FORUMS: list search recent posts

Scale Image Between Two Nulls

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jesse Stormer
Scale Image Between Two Nulls
on Oct 14, 2014 at 7:31:43 am

Lets say I have two nulls that I want to animated independently. I'll use an expression to find half way between their position (that's the easy part) no problem. Here's where I'm racking my brain... an expression to find the scale of the image between these two points... While maintaining the aspect ratio.

I've got this far:

I know that it's essentially two different expressions. One finds the X distance between the two nulls, and finds the scale. Another finds Y distance between the two nulls, and does the same. But then it needs to have a 'choose the lesser value' expression to pick which one to use at that given time. (Because remember, I need to maintain the aspect ratio)

Has anyone ever attempted this before?


Return to posts index

Jesse Stormer
Re: Scale Image Between Two Nulls
on Oct 14, 2014 at 8:04:21 am

I've made it a little farther... now I just need to figure out the 'if\then' parts...

x = (thisComp.layer("Upper Right Null").transform.position[0]-thisComp.layer("Lower Left Null").transform.position[0])/1920;
y = (thisComp.layer("Lower Left Null").transform.position[1]-thisComp.layer("Upper Right Null").transform.position[1])/1080;


[x, y]


Return to posts index

Jesse Stormer
Re: Scale Image Between Two Nulls
on Oct 14, 2014 at 8:10:42 am

WOW I am really pleased with myself. I figured it out. Hopefully this helps someone else.

x = (thisComp.layer("Upper Right Null").transform.position[0]-thisComp.layer("Lower Left Null").transform.position[0])/19.2;
y = (thisComp.layer("Lower Left Null").transform.position[1]-thisComp.layer("Upper Right Null").transform.position[1])/10.8;


if (x<y){
[x, x];
}else{ [y, y] ; }


Return to posts index


Jesse Stormer
Re: Scale Image Between Two Nulls
on Oct 14, 2014 at 8:44:06 am

Well crap. That doesn't work with parenting, I had to modify it to work with world position.
Now I broke my 'find position half way between two nulls' expression.

how do i convert this to use world position? (it finds the location half way between two nulls/positions)

x = (thisComp.layer("Upper Right Null").toWorld(anchorPoint)[0]-thisComp.layer("Lower Left Null").toWorld(anchorPoint)[0])/2;
y = (thisComp.layer("Lower Left Null").toWorld(anchorPoint)[1]-thisComp.layer("Upper Right Null").toWorld(anchorPoint)[1])/2;
[x, y]


Return to posts index

Jesse Stormer
Re: Scale Image Between Two Nulls
on Oct 14, 2014 at 8:56:30 am

I hope I'm entertaining someone... just going on and on to myself.

Here's the expression to find the world position half way between two nulls/positions:

x = [(thisComp.layer("Upper Right Null").toWorld(anchorPoint)[0]+thisComp.layer("Lower Left Null").toWorld(anchorPoint)[0])/2]-960;
y = [(thisComp.layer("Lower Left Null").toWorld(anchorPoint)[1]+thisComp.layer("Upper Right Null").toWorld(anchorPoint)[1])/2]-540;
[x, y]


Here's the expression to scale the image between them - also using world coordinates.

x = (thisComp.layer("Upper Right Null").toWorld(anchorPoint)[0]-thisComp.layer("Lower Left Null").toWorld(anchorPoint)[0])/19.2;
y = (thisComp.layer("Lower Left Null").toWorld(anchorPoint)[1]-thisComp.layer("Upper Right Null").toWorld(anchorPoint)[1])/10.8;


if (x>y){
[x, x];
}else{ [y, y] ; }


Return to posts index

Chris Meadmore
Re: Scale Image Between Two Nulls
on Nov 8, 2014 at 10:01:20 pm

Hugely entertaining thanks! :D

Can you show me how to make this only affect the x scale and ignore the y?

Basically I want my layer to expand horizontally.

Thanks


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]