Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

Expression for Trimmed Paths on Dashed Lines

$
0
0

I'm editing a trim paths expression and have run into a little nuanced issue.

The smoke animation below (rendered quickly for demo purposes, so no judging) is going to be a sort of neon light animation (as is the rest of the comp), I just haven't gotten that far into building this. I slowed down the footage a little so you can see my problem, which is that the yellow dashed stroke is not lining up with the gray dashed stroke, though they have the exact same paths and dash settings.

 

The only difference is that the yellow stroke has an expression that tells it where on the path it needs to be. This is applied to the end of the path:

total = 5;
step = 100/total;

cycledur = .75;
t = (time - thisLayer.inPoint); 

if (t < cycledur) {     y = (step/(cycledur - cycledur/total))*(total-1)*t + step;     ynorm = y/step;     ret = step*Math.floor(ynorm);
} 
else {     ret = 0;
}
ret

 

and yes, before you say it: I defined a linear function by hand when I had the linear() method at hand. Oops. I forgot about it for a second.

 

What's actually happening? Inside the if conditional, I am taking the result of the linear function, then dividing it by the step value. Once that is done, I find out if I have reached the next step or not using the floor() function. Then I multiply back to get to the actual step.

(I put in some magic numbers that are actually defined in a null object layer, but that's just so you can see the numbers.)

 

The start property of trim paths simply reads the value returned in the above expression and subtracts the by the step number:

//step defined up here

endv = content("blahblah")...end;
endv - step;

 

The animation loops, and I have a debug text layer in the below animation showing the value of end on the rightmost path.

Notice that it is actually reaching 100% but also that the actual path ends well past the point it reaches. The silver lining is that it is following the path I guess.

 

How do I get one path to line up with the other? I can post pictures of the dashed line settings too, but there is no difference between the two.

 

 

cig_1.gif

 

UPDATE: I think I have begun to solve the issue. The start value of Trim Paths actually defines where the dashed line starts (or so it seems). Since the path does not exist yet, it is possibly just traveling 80% along the path (for example), starting there, then going 20% of the dashed-line distance. Since that 20% is not entirely stroked, I am receiving a little bit of the un-dashed areas, which is why it doesn't *appear* to go the full 100%. Okay. I will search for a solution to my boldfaced question, but I now know how to explain the discrepancy.


Combine two KeyframeLess expressions

$
0
0

Hey!

so i have this expression:

 

 

function easeInOutCubic(t) { return 1-(--t)*t*t*t };

 

 

startVal = 0;

endVal = 100;

startDur = inPoint;

endDur = (inPoint+outPoint)/2;

 

 

t = linear(time,startDur,endDur,0,1);

e = easeInOutCubic(t);

x = linear(e,0,1,startVal,endVal);

[x,x];

 

 

and this one:

 

function easeInOutQuart(a) { return a*a*a*a };

 

 

startVal = 100;

endVal = 0;

startDur = (inPoint+outPoint)/2;

endDur = outPoint;

 

 

a = linear(time,startDur,endDur,0,1);

b = easeInOutQuart(a);

c = linear(b,0,1,startVal,endVal);

 

[c,c];

 

 

And they work perfectly.

but i want to connect them to one animation(In and out).

obviously when i put them one after the other:

 

function easeInOutCubic(t) { return 1-(--t)*t*t*t };

 

 

startVal = 0;

endVal = 100;

startDur = inPoint;

endDur = (inPoint+outPoint)/2;

 

 

t = linear(time,startDur,endDur,0,1);

e = easeInOutCubic(t);

x = linear(e,0,1,startVal,endVal);

[x,x];

 

 

 

 

function easeInOutQuart(a) { return a*a*a*a };

 

 

startVal = 100;

endVal = 0;

startDur = (inPoint+outPoint)/2;

endDur = outPoint;

 

 

a = linear(time,startDur,endDur,0,1);

b = easeInOutQuart(a);

c = linear(b,0,1,startVal,endVal);

 

[c,c];

 

 

it doesnt work.

any idea how can i mix them?

Scale over time expression

$
0
0

I'm trying to have an element scale up and do so through an expression:

 

startScale = 100;

endScale = 300;

scaleUpTime = 5;

 

s = ease(time, inPoint, inPoint + scaleUpTime, startScale, endScale);

[s,s]

 

 

This works but I'd like to modify this is that the endScale is actually a random number between 100 and 300.

I'd also like the whole thing to trigger at a specific time (or frame).

 

I tried random(100,300) but it gives a jittery result not a constant scale up to a random value

After Effects Font Expression

$
0
0

Dear AE expressionators,

 

Concrete: I am making a template whereas the user can change the text font and that it will automatically update this to the hole template.

 

For example, see the picture.

So everything I change in the above text layer the under text layer transforms with it. But if I change the font it doesn't.

Does after effects use a different expression for automatically changing a font?

 

I would really appreciate your help!!!

 

I'm using after effects CS6

Advanced expression (position) question

$
0
0

I'm usually pretty good with expressions, but I'm really stumped on this one:

 

For the sake of keeping it simple, let's say I have:

1. A layer

2. A null object with a slider

 

I want my layer to slide in (x position only) from Point A, to Point B, pause on Point B for a few seconds, then slide back to Point A.

 

Here's the challenge: I want Point B to be controlled by the slider, but I always want Point A to be the same exact starting/ending point. (say 0, for the sake of simplicity). So the animation should go:

 

0 to X, then X back to 0, where X is the value driven by the slider.

 

Hope this makes sense. Thank you in advance to anyone who might be able to help.

Help with write on text with curser using an expression

$
0
0

Hi There,

 

I have text writing on with a cursor using this TUT: AE Tut'z - How to Create a Type-Text Effect with a Blinking Cursor - YouTube

 

L = text.sourceText.length;
T = time*effect("Speed")("Slider") -effect("Start At")("Slider")* effect("Speed")("Slider");
F = Math.round(time % 1);

if(F == 1 | (T<L & T>0)){Fl = "▇";}else{Fl=" ";}

substr(0,T) + Fl

 

 

Questions:

 

1.

How would I double the speed of the cursor blink?

Have tried 0.5 under time and the if statement (and tried 2) but then the cursor doesn't show at all.

 

2.

How can I make the cursor start on, then blink?

Currently it starts off but it should be on to start. I tried swapping the cursor "▇"in the if/else statement but then the cursor doesn't show while the text types on (as expected).

 

 

Pretty green when it comes to this stuff so any help or pointers in the right direction would be juch appreciated.

 

Cheers

 

Ben

Expression depending on 2 checkboxes

$
0
0

Good day everyone,

 

In AE, I synced 4 different versions of 1 short video (a white/alpha transition for the Track Matte Key effect), so when I import it into the Graphic Essential Panel, it would be possible in Premiere Pro to toggle on a hard-keyed version, a speed-up version and a combination.

Schermafbeelding 2017-10-16 om 16.35.06.png

The plan is to do it by the following scheme:

Hard-key: OFF

Speed 2x: OFF

= video 1 (soft-key, speed 1x) 100% opacity.

= video 2 (soft-key, speed 2x) 0% opacity.

= video 3 (hard-key, speed 1x) 0% opacity.

= video 4 (hard-key, speed 2x) 0% opacity.

 

Hard-key: OFF

Speed 2x: ON

= video 1 (soft-key, speed 1x) 0% opacity.

= video 2 (soft-key, speed 2x) 100% opacity.

= video 3 (hard-key, speed 1x) 0% opacity.

= video 4 (hard-key, speed 2x) 0% opacity.

 

Hard-key: ON

Speed 2x: OFF

= video 1 (soft-key, speed 1x) 0% opacity.

= video 2 (soft-key, speed 2x) 0% opacity.

= video 3 (hard-key, speed 1x) 100% opacity.

= video 4 (hard-key, speed 2x) 0% opacity.

 

Hard-key: ON

Speed 2x: ON

= video 1 (soft-key, speed 1x) 0% opacity.

= video 2 (soft-key, speed 2x) 0% opacity.

= video 3 (hard-key, speed 1x) 0% opacity.

= video 4 (hard-key, speed 2x) 100% opacity.

Schermafbeelding 2017-10-16 om 16.16.22.png

The only thing is, I'm looking for a way to make the opacity of each layer depending on 2 checkboxes (in instead of 1).

Trying to let it depend on just 1 checkbox with expressions already succeeded (see above)

Random wheel spin (wheel of fortune-esque)

$
0
0

Hi,

 

I am trying to essentially create a prize wheel that will rotate a random number of times in a set time frame yet will still ease to a stop no matter how fast it starts out.  I am fairly new to After Effects so I am not familiar with the random function or how I would properly apply it to the rotation. 

 

To summarize, if my animation were 5 seconds long, I would want to randomize the rotation so that it spins somewhere between 10-15 times within that 5 seconds yet still properly eases to a stop (to simulate how an actual wheel would spin).  Thank you!


Time Remap Expression

$
0
0

I'm trying to do trigger a keyframe for a timeremap using an expression as follows, but after I put in the expression the output goes black:

 

 

  • Did a timeremap on the precomp.
  • Put in two keyframes. One where I need the comp to start, second where it ends.
  • Then I used the following expression:

        clockStart = parseInt(comp("main").layer(5).text.sourceText.value); 

 

        t = linear(time,0,clockStart+1,0,key(1).value+time);
        valueAtTime(t);

 

clockStart here is basically where I want the composition to trigger In. So my first keyframe.value is 14, Second keyframe.value is 20. If my clockStart is 10. At the start of the play the value of the timeRemap for this layer/comp is set to 14 (first keyframe value). Then when it plays, and clockStart reaches 10 then the timeremap start's counting in from 14 onwards until the second key frame (value is 20). This seems to work as I want but the issue is the output goes black I don't have any output while the expression is enabled on the time Remap. I tried looking for other properties like opacity but all are set properly and opacity is 100per. THe moment I remove the expression I have output on it. What can be wrong with this expression ?

Fill Color Controller to change between colors overtime

$
0
0

Hi All,

 

I'm using CS6 AE..

 

I have created a clapometer style animation that uses a colour controller and value/numbers controller to animate the hand from left to right of a semi circle. As the hand moves (by a value slider) the layer underneath fills and I would like the color to go from yellow to red via multiple colors.

 

So far I have this code on my fill layer

 

l=thisComp.layer("Fill color controllers");

i=1;

colors=[];

try {

while(l.effect(i)) {

if (l.effect(i)(1).name=="Color") {

colors.push(l.effect(i)(1).value);

}

i++;

}

} catch (e) {}

if (colors.length) {

r=Math.floor(random(colors.length));

colors[r];

} else {

}

 

And a fill color controller layer with 5 different color expression controls. At the moment the code cycles through them randomly, but I would like cycle through the list. I know there are other ways I could do this but I am trying to improve my expression knowledge and hope someone can help me!

 

Cheers!

Master Expression for Multiple Layers

$
0
0

Working on a project that may have many hundreds of layers, and while many will have the same animations with time offsets etc I need to build it as an adjustable template.

 

Effectively I'm looking for a way to have many layers using the same expression from a single control layer so that if I want to make modifications to the expression I don't have to go through 100+ layers and re-paste the expression.

 

Ideal scenario would be to have an "Master Expressions" layer which has many properties with the applied expressions and then on all my other layers have them pull the expression code from the appropriate "Master Expressions" property. This way when I update the code in the "Master Expressions" it is applied globally across all linked layers.

 

I've attempted to use a Text Layer and input my expression in the "Source Text" parameter, but I have not found a way to pull the full text as applied expression for another layer.

 

Any ideas?

Add a delay to an expression

$
0
0

So I have an expression that controls the opacity something along the lines of

 

if(other layer >50) opacity(100) else opacity(0)

 

is there a way I could stick a delay in the else part of my expression. Logically I want the opacity to go to 0 but i want it to wait a second before it does. Would it be something like

 

else opacity(0) delay(.1)

 

i don't want to delay the whole expression just the part that makes the opacity go to 0

 

any help would be great

wiggle between parameters

$
0
0

I want to wiggle between 2 values. So that my glow stays bright enough to see and still flickers.

 

why would this not work?

 

x= (50-75)

wiggle(4,x)

expression for 23.98fps smooth credit roll

$
0
0

Hi,

can anyone tell me the expression for a smooth credit roll in 23.98? I can only find the one for 29.97

sourceRectAtTime() expression to change key-framed position of solid based on text layer width

$
0
0

Hello,

 

I am making a series of fully-customizable lower-thirds, that automatically scale / change based on the width of any given text layer. I have had success with linking the width of a shape layer to the width of a text layer using the following expression:

 

s=thisComp.layer("FIRST NAME")

x=s.sourceRectAtTime(time-s.inPoint,true).width;

[x, value[1]]

 

I also have a position expression linked to the size.

 

content("Rectangle 1").content("Rectangle Path 1").size/2

 

 

Here is my question:

 

If I want to link a key-framed "end position" of a shape layer to the width of a text layer, how would I go about that? Below is a video of my current animation. A square rolls in then splits in two to reveal text. I want the right half of the square to automatically animate further away based on the width of the text layer. My goal is to make this as user-friendly as possible, so even an 'After Effects Novice' can edit and export!

 

 

The shape layer in question has key-framed animation on both the x-scale, and the x-position. The keyframes are eased and velocity adjusted as below.

 

keyframe velocity.JPG

 

I do realize that I'll also have to write an expression to scale the Alpha Matte in relation to the width of the text layer (which should be similar to my first expression at the top), but that's nothing I can't handle.

 

Please Help!!!


Expression to duplicate whole layer several times.

$
0
0

Hi everyone,

 

I am pretty new with AE, I want to ask if there is an expression, which would let me duplicate selected layer?

I want to use expression, because I have to use like, 30 layers of same object, only with some position and rotation offsets.

 

THank you.

Dynamic keyframe value using expression?

$
0
0

Hi, I'll try my best to explain myself here.

 

I currently have an animation of a Shape Layer using two keyframes controlling the width of the the shape from 0 px to 100 px.

Now what I want to do is to have the second keyframe value be controlled by an expression (so I can link it & make it "dynamic") WHILE retaining the animation curves (velocity) from my predefined keyframes. Is this at all possible? In my mind it seems pretty basic as I just want to change the value of a specific keyframe while retaining the timing and speed of the predefined keyframes.

 

All I've seen are solutions where they replace the whole animation with some default ease or linear curve. It's crucial for me here to retain the predefined animation.

 

I'm thinking a solution would be as simple as this in the expression window:

 

key(2).value = [x, y];//where I then would be able to set x to sourceRectAtTime().width of a specific object

 

 

 

Thanks in advance!

How to control only the WIDTH of a rectangle with slider control using expression

$
0
0

I have a simple rectangle shape layer that I want to control (only the width) with slider control using expression. How do I do that?

 

Thanks in advance.

follow a leader with delay

$
0
0

hi

 

i have bunch of layers all distributed in z space.All in a row.So,they have all differenent position data.

Now the first layer starts to move towards the camera.After a specific time i.e 1.5 secs i want to move the second layer to move with the first one.etc.

 

thisComp.layer(thisLayer,-1).position.valueAtTime() doesn't work.

 

something similar to this>

start = 0; //start time of template motion
end = 4.0; //end time of template motion

 

t = thisComp.layer("template");
offset = (t.effect("offset")("Slider")/100)*(index -1);
travel = linear(t.effect("travel")("Slider")/100,start,end);
t.position.valueAtTime(travel - offset)

 

any ideas?

cheers

Getting global coordinates from parented local coords.

$
0
0

I have a mocha tracked null. I child another null thats slightly offset in XY. Now the child's coordinates are relative to the parent. But how can I get the child's true position in the comp?

 

This seems too easy:

 

thisComp.layer("parentNULL").transform.position + thisComp.layer("childNULL").transform.position

 

Am I missing something?

Viewing all 47983 articles
Browse latest View live