Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using Expressions to determine direction of a stroke and show one of two pics depending on direction

  • Using Expressions to determine direction of a stroke and show one of two pics depending on direction

    Posted by Johannes Schwarz on December 26, 2011 at 7:55 pm

    Hi,

    I know, the description in the title will provoke curiosity rather than give a clear understanding of what I’m trying to do – namely a crossover look between animation and stop motion…

    What I’m after is this:
    1) I have a hand drawn figure. check.
    2) I would like to animate it onto the screen using the stroke effect, so it looks like being quickly drawn on (over 2 secs). check.
    3) To make things more artsy and interesting I would like to use a still photo of a hand with a pen that follows the reveal of the stroke effect. I haven’t done this yet, but I think this should be possible.
    4) Now to really make it interesting I would like to use 2 or more stills of the hand with a pen (all slightly different in posture). Which picture of the hand is displayed should depend on the direction of the stroke at the time. If the stroke follows an upward path show pic1 and if downward show pic2. More variations are possible: show pic 3 if the motion is up and right…etc. This way, the “draw on simulation” is even more lively and it should look cool 😉

    So here’s the question:
    Is there a way to link these things: increase or decrease of x or y value from one frame to the next + opacity value of pics?

    a) Can this be even done using expressions?
    b) any insightful threads or tips for doing something like this?

    Cheers from snowy Liechtenstein,
    Johannes

    Dan Ebberts replied 14 years, 4 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    December 26, 2011 at 9:18 pm

    Since expressions don’t have direct access to mask/path data, this is the best I can come up with. Add a null. Copy your mask path and paste it into the position property of the null. That should give you a two-second animation of the null that traces out the path. Add a slider to the null. Add this expression to the slider (change the layer name in the first line to match that of your stroke layer):

    pct = thisComp.layer(“Yellow Solid 1”).effect(“Stroke”)(“End”);
    v = transform.position.velocityAtTime(2*pct/100);
    radiansToDegrees(Math.atan2(v[1],v[0]))

    The slider should give you the angle corresponding to the stroke’s current end percentage. You should be able to use that to select the appropriate hand.

    Dan

  • Johannes Schwarz

    December 27, 2011 at 8:35 am

    Dear Dan,

    thanks very much for your response and your time to look at this. I followed your suggestion. As I scrub through the timeline however the slider remains constant at -180.

    Thanks for you help,
    Johannes

  • Dan Ebberts

    December 27, 2011 at 2:07 pm

    Are you animating the stroke end percentage over the period you’re scrubbing? That’s the only thing I can think of. It works for me.

    Dan

  • Johannes Schwarz

    December 28, 2011 at 9:00 am

    Hi,

    Thanks again for your reply. I did animate the stroke end percentage, but I haven’t gotten the expression to work yet. If I don’t, then I’ve found a way round. Instead of alternating stills, I just record a video of the hand changing positions. Then I stabilize the motion around the tip of the pen and parent it to the null so it follows the motion of the line being drawn on. It will lack the staccato feel, but I think it will do.

    If it works on your end, could I kindly ask you to share the project file, to see where my mistake is?

    Thanks Dan for your help,
    Johannes

  • Dan Ebberts

    December 28, 2011 at 2:24 pm

    There just aren’t that many places where it could be going wrong. Is the null tracing out the path over the first two seconds of the comp? Does your comp start at time 0?

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy