ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Generate paths via expressions

FAQ   •   VIEW ALL
 Generate paths via expressions on Sep 28, 2018 at 4:44:52 pm

I build a lot of vital screens(EEG and EKG) in after effects. I know I can draw them out in either after effects, illustrator or even finds them on google images. But they are static at that point. I need to be able to generate them because I need to control points. (i.e. lines go crazy and then flatline). I know ae has the path expressions now but I can't think of a way to even start.

 Re: Generate paths via expressionson Sep 28, 2018 at 8:33:20 pm

I'm not sure what you're after, but here's an example. Create a square solid, click inside it with the pen tool to create a mask point, then add this expression to the Mask Path property to create a circular closed path:

r = width/2;
ratio = .5523;
t = r*ratio;
vertices = [[r,0],[0,r],[r,2*r],[2*r,r]];
inTangents = [[t,0],[0,-t],[-t,0],[0,t]];
outTangents = [[-t,0],[0,t],[t,0],[0,-t]];
closed = true;
createPath(vertices,inTangents,outTangents,closed);

Dan

 Re: Generate paths via expressionson Sep 28, 2018 at 10:53:23 pm

If you wanted to animate it, you could do something like this:

r1 = width/25;
r2 = width/2;
dur = .5;
c = [width,height]/2;

r = ease(time,inPoint,inPoint+dur,r1,r2);
ratio = .5523;
t = r*ratio;
vertices = [c+[0,-r],c+[-r,0],c+[0,r],c + [r,0]];
inTangents = [[t,0],[0,-t],[-t,0],[0,t]];
outTangents = [[-t,0],[0,t],[t,0],[0,-t]];
closed = true;
createPath(vertices,inTangents,outTangents,closed);

Dan

 Re: Generate paths via expressionson Oct 2, 2018 at 2:23:37 pm

I've successfully done EKG lines in AE before; it would be possible to code out a single path to do this, but it would be pretty difficult, since AE does not use any sort of functions to generate lines, but uses vertices data to build them, and it would be very very difficult to control that at all times.

I would suggest you explore using shape layers with blend modes to intersect and merge spike paths with a horizontal line, and then matte them. Use a 'path offset' set to 0 if you're having difficulty with getting paths to blend.

How I have done my ekg's it in the past is created a master shape, and animated that over time, going from flatline to intense.

Then I would make child shape layers for each spike that would reference their own name, offset their position relative to their name times some 'offset' slider value, and then based on another 'intensity' slider assume the path data value of the master shape at a certain time and hold that throughout.

I never rigged the rate of spikes to be different (was doing technology analogies but not organic applications), but I guess you could add another 'density' over time to increase the density (or offset) of the layers; their positions would probably have to be recursive though to check the density of all other layers prior to themselves, which would make the expression a pain to calculate each frame.

Alex Printz
Mograph Designer