Hello all!
First of all, i was inspireed by this expression; hxxp://www.motionscript.com/expressions-lab-ae ... lines.html
Now what I am after is, to use an animated Mask instead of the layer.
I have heard it many times, this is slightly impossible to do.
But after some Trial and Error-phases i realized this;
A Mask equals a position path.
When you have a rectangle mask, make a keyframe.
Whenever you copy this keyframe into another layers position property, you will notice 5 keyframes. `The first Keyframe is the position of the UpperLeft Vertice from your mask. the 2nd is the lowerleft position, the 3rd the lowerRight, the4th the upperright. The 5th keyframe is kind of useless.. its the connection between the 4th and 1st keyframe.
Lets say, this layer (with the 5 keyframes) we will name; keyframeLayer.
anyway.. I made 4 other solids;
UpperLeft: Position should equal the 1st keyframe from keyframeLayer.
LowerLeft: ,, ,, ,, ,, 2nd keyframe from keyframeLayer
LowerRight:,, ,, ,, ,, 3rd keyframe from keyframeLayer
UpperRight:,, ,, ,, ,, 4th keyframe from keyframeLayer
Is there an expression wich copies a keyframe into another layers property?
I want the position property of keyframeLayer to copy the keyframe from the animated mask.
And the 4 other layers to copy every 5th instance after the first keyframe;
For Upperleft this will mean it should copy keyframe no#1 and then the 6th,11th, etc etc.
Is this possible?
Hope you experts can help me!
Best Regards,
Using mask boundry box as a reference
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
At first I thought you were nuts. ![Smile :-)](./images/smilies/icon_smile.gif)
But now I think you might be on to something. There's still some work to do on this, but it's fun to play around with. This is a position expression for a layer to track a mask vertex on another layer. It assumes that the layer with the mask is named "target", that the mask's keyframes have been pasted into the corner layer's position, that the mask has 4 vertices, and the keyframes are linear. It also assumes that the corner layers are the top four layers in the layer stack.
Interesting stuff.
Dan
![Smile :-)](./images/smilies/icon_smile.gif)
But now I think you might be on to something. There's still some work to do on this, but it's fun to play around with. This is a position expression for a layer to track a mask vertex on another layer. It assumes that the layer with the mask is named "target", that the mask's keyframes have been pasted into the corner layer's position, that the mask has 4 vertices, and the keyframes are linear. It also assumes that the corner layers are the top four layers in the layer stack.
Interesting stuff.
Code: Select all
offset = 1;
m = thisComp.layer("target").mask("Mask 1").maskPath;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time){
n--;
}
}
if (n == 0){
value;
}else{
t1 = m.key(n).time;
if (m.numKeys > n){
t2 = m.key(n+1).time;
linear(time,t1,t2,valueAtTime(key((n-1)*5 + offset).time),valueAtTime(key(n*5 + offset).time))
}else{
value;
}
}
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
This is getting better. ![Smile :-)](./images/smilies/icon_smile.gif)
It appears to work with bezier mask points as well. And it works with more than four. One limitation is that you have to specify in the expression how many vertices there are (can't get at that info with an expression). I also corrected the code so that the follower layers stay in position after the last mask keyframe.
Dan
![Smile :-)](./images/smilies/icon_smile.gif)
It appears to work with bezier mask points as well. And it works with more than four. One limitation is that you have to specify in the expression how many vertices there are (can't get at that info with an expression). I also corrected the code so that the follower layers stay in position after the last mask keyframe.
Code: Select all
numVertices = 4;
offset = index;
m = thisComp.layer("target").mask("Mask 1").maskPath;
n = 0;
k = numVertices + 1;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time){
n--;
}
}
if (n == 0){
value;
}else{
t1 = m.key(n).time;
if (m.numKeys > n){
t2 = m.key(n+1).time;
linear(time,t1,t2,valueAtTime(key((n-1)*k + offset).time),valueAtTime(key(n*k + offset).time))
}else{
valueAtTime(key(numKeys - index +1).time);
}
}
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
OK - one more thing. If you easy ease all the mask keyframes, all you have to do in the expression is change linear() to ease(). Try it - it's very cool. ![Smile :-)](./images/smilies/icon_smile.gif)
Dan
![Smile :-)](./images/smilies/icon_smile.gif)
Dan