Activity › Forums › Adobe After Effects Expressions › connect objects with stroke
-
connect objects with stroke
Posted by Peter Müller on June 12, 2010 at 12:49 pmHi everyone,
I searched around the net for an expression that automatically connects two (or more) objects (circle, rectangle, whatever) with a stroke.
It should be a flexible stroke that starts at an object and ends by creating a new object at the end of the stroke.Can someone give me some hints or a solution?
Thanks!
greetings
peterChris Vile replied 10 years, 6 months ago 5 Members · 10 Replies -
10 Replies
-
Filip Vandueren
June 12, 2010 at 5:38 pmThe easiest way would be to have the two shapes as separate layers,
Then have third layer with the beam effect set up where you pick whip start and end position to the position of the two layers.
Then you set up the beam effect to be 100% long. -
Peter Müller
June 12, 2010 at 5:53 pmThanks Filip for your answer.
I tried and it works.But as I also mentioned, I would like to have a flexible stroke.
Is it possible to have an automatic bend of the “beam” stroke, so that the line is not just straight and more like an elastic curve?
And the other point was to have the second object appearing then, when the stroke is ending. I think this would need a time expression for the effect?I imagine something like a network effect, where one object appears, then the elastic stroke flows out and then the connected object appears at the end…and so on.
thanks again! 🙂
-
Filip Vandueren
June 13, 2010 at 1:06 amBy “elastic” do you mean it’s just not a straight line, but arched, or is it actually changing shape as it shoots out (that woud be pretty hard to achieve in After Effects without just animating a line by hand)
If you just need a bend in the line, you could try adding a “CC Bender” effect (style: Marilyn) after the beam, though I never really liked the way that looks.
Alternative 1: if the objects are fixed in position, you’re better off drawing a Path-shape as curvy as you want and add a “Trim Paths” to animate that.
Alternative 2: use a solid that get’s rescaled to be a line between two objects, use a linear wipe to animate it, and add a Distort->Warp effect to have a bend in it.
Here are the expressions you need to turn a solid into a connecting line:
– make a solid, comp width x stroke thickness for height, example: 1920x16px;
– expressions=>
anchorpoint:
[0,height/2]position:
thisComp.layer(“A”).transform.position;scale:
a=thisComp.layer(“A”).transform.position;
b=thisComp.layer(“B”).transform.position;
l=length(a,b)/width;
[l*100,100];rotation:
a=thisComp.layer(“A”).transform.position;
b=thisComp.layer(“B”).transform.position;
r=Math.atan2(b[1]-a[1],b[0]-a[0]);
radiansToDegrees(r);– add a “linear wipe”, change angle to -90°
– add Distort->Warp and set the bend factor to something sensibleThen just keyframe the wipe, and the 2nd object fading or popping up as the line is finished.
This 2nd solution will work if the 2 objects are moving because of a wiggle for example.
-
Peter Müller
June 13, 2010 at 11:41 amwow, wonderful! thanks!
I played a little bit around and tried to get the object appearing when the stroke ends depending on the linear wipe. The effect is, that the object already appears at about the last third of the line path.
But I want the object to appear right at the moment the 100% linear wipe is reached with some kind of pop up wiggle effect?This is my last question and wish to be fulfilled 🙂
Much appreciation for your work. Great to have such a professional forum!
greetings
-
Filip Vandueren
June 15, 2010 at 11:30 pmHey,
I’ve been thinking about this, and the best way I can find is to create an expression control Slider somewhere (on the connecting line for example)
We will animate this slider from 0 to 100, and this slider will control the wipe, and the scaling of the objects A and B.So let’s start with what we had:
– two objects A & B.
– a solid with expressions to make it into a line connecting A and B. I named this Solid “connect line”. Make sure it has the WipeHere’s what to do next:
– Create an expression-control Slider on the “connect line” layer, and name it “completion”
– give the linear wipe (at -90°) this expression for Transition completion:
t=effect("completion")("Slider");
st=0;
en=60;
linear(t,st,en,100,0);
Now if you slide the slider from 0 to 100 you’ll see this of course controls the wipe, between 0 and 60-Add this expression to object A’s scale:
t=thisComp.layer("connect line").effect("completion")("Slider");
st=0;
en=40;a=linear(t,st,en,-180,360);
b=easeOut(t,st,en,1,0);
osc=Math.cos(degreesToRadians(a));(1+osc*Math.pow(b,2))*value;
– and this for object B: the same, just different values for variable st and en:
t=thisComp.layer("connect line").effect("completion")("Slider");
st=60;
en=100;a=linear(t,st,en,-180,360);
b=easeOut(t,st,en,1,0);
osc=Math.cos(degreesToRadians(a));(1+osc*Math.pow(b,2))*value
set a keyframe 0 for the completion slider, and a keyframe 100 about 2 seconds later.
The different linear and easeOut functions in the three expressions each make sure aniation happens at a certain part of this 0 to 100% cycle:
object A pops up between 0 and 40, at the same time the stroke starts wiping.
At the moment the wipe is complete (60%) Object B pops up, and takes 40% of the time to finish it’s popup animation, the same as object A.https://reels.creativecow.net/film/animated-stroke-and-popups
The Math part takes care of having an oscillation/overshooting tot the pop-up effect.
in the line “a=linear(t,st,en,-180,360);”
Try different values for 360 (for example 0,180,720) and you’ll see more or less elastic popups. -
Peter Müller
June 16, 2010 at 8:31 amAbsolutely amazing, exactly what I needed!!!
Thank you filip, great work.
greetings
-
Sigurd Kristiansen
May 18, 2011 at 1:18 pmThis is exactly what I need, and it works perfectly until I try to use 3D layers – for some reason the line connecting the nulls gets offset when I make the layers 3D and move the nulls along the Z axis.
I am very new to expressions and scripting, there’s probably an easy solution to this, sorry if it’s a stupid question. Hope someone has the time and patience to help me out, would be much appreciated!
-
Chris Vile
November 18, 2015 at 10:59 pmYOU ARE SO CRAZY AWESOME DUDE !
🙂
Thanks alot!
Always so hard to handle expressions in AE…
Greets!
Chris
Reply to this Discussion! Login or Sign Up