9 Replies Latest reply on Sep 28, 2013 6:35 PM by notbyhalf

    Paint stroke End property interpolation

    notbyhalf Level 1



      This is possibly only answerable by someone on the Adobe Dev team, but here's my puzzle:


      I have been working a lot with the Paint Effect lately and have been trying to understand exactly how the brush strokes are drawn on when the End property is animated from 0 to 100%.  (as described in the Adobe help pages: http://help.adobe.com/en_US/aftereffects/cs/using/WS3878526689cb91655866c1103a9d3c597-7c84 a.html#WS3878526689cb91655866c1103a9d3c597-7c66a)


      If I copy the path from a Brush Stroke to the position of a null (a default durations of 2 seconds) and drag the keyframes out to the same duration as the 0-100% End Property keyframes, I am expecting the null to move in relation to the end of the Stroke - appearing to draw it on. However, the temporal interpolation of the Stroke being drawn on appears to be non-linear but I can't figure out how a the percentage is determined if not by path length.  The null position and the End of the stroke appear to be moving at two different paces. 




      By shift-clicking it is possible to draw paths with straight lines and with vertices further apart than the sampling rate places them when drawing with a stylus.  I figured that a path with only a few vertices would be simpler to analyse.  I assumed that the stroke length was known (by measuring and adding the length of each segment between vertices), and that the percentage (on the End property) was directly related to distance along the path.  However with longer straight segments the "write-on" interpolation becomes even more perplexing.  If a Stroke is selected in the Layer viewer, you can see the path being drawn on and the resulting Paint stroke revealed.  If I copy this path to a position property, not only do the path End and position vary in position, but the revealed Paint stroke doesn't necessarily match the end of the path either!


      I'm at a bit of a loss and was hoping that there was an explanation (perhaps a definitive temporal/spatial relationship I'm missing).  If anyone has any ideas on how to do some data modelling on the behaviour of the Stroke End property percentage I'm open to suggestions.  I am looking to script a solution and even tried setting positions vertex-by-vertex with keyframe time based on the percentage along the length of the path ... but I get identical keyframes to copying and pasting the path to a Position property.


      Thanks for reading,


        • 1. Re: Paint stroke End property interpolation
          Dave LaRonde Level 6

          Let's eliminate the obvious: you didn't alter the null's Anchor Point, correct?

          • 2. Re: Paint stroke End property interpolation
            notbyhalf Level 1

            Hi Dave,


            Thanks for the quick reply


            No, the anchor point has not been altered.  The null follows the path position precisely, just not at the same speed as the transition of the stroke End property from 0 to 100%. 


            The end goal is to use the position data (which is currently being tested on a null) to drive the position of a layer, which could be an image of a paint brush or pencil, so that it looks like it is painting the brush stroke.



            • 3. Re: Paint stroke End property interpolation
              Dave LaRonde Level 6

              Oh, duh!  Now I forgot the obvious!  If you used a Mask Path to make the line, you're in luck.  Make a keyframe for the mask path, then copy.  Paste it into the null's position property and match up the beginning & ending keyframes the the 0% & 100% brush keyframes.  It ought to work.

              • 4. Re: Paint stroke End property interpolation
                Rick Gerard Adobe Community Professional & MVP

                Press u to reveal the keyframes and adjust the timing.

                • 5. Re: Paint stroke End property interpolation
                  notbyhalf Level 1

                  That was my thought too, but it seems that while the roaming keyframes match up to the position of each vertex on the path, they don't match up in time to the brush stroke transition along the same path. 


                  With a brush stroke that has only a few vertices like the example above I could take on Rick's suggestion to move they keyframes around (I'd have to change them from roaming to regular keyframes) so that each position keyframe matches the timing of the stroke writing on.  Ideally I'd like to know how 0-100% on the End property is being processed so that this doesn't have to be done manually (it doesn't seem to be percentage of total stroke length).

                  • 6. Re: Paint stroke End property interpolation
                    Mylenium Most Valuable Participant

                    You are simply ignoring that spatial and temporal interpolation are separate for some transform operations. It behaves correctly and predictably, you just haven't set both parameters to be linear.



                    • 7. Re: Paint stroke End property interpolation
                      notbyhalf Level 1

                      What I am particularly interested in is how the percentage relates to the distance along the path.  I thought I'd do another test, and in this example (see GIF) I have drawn two brush strokes, each with the same number of vertices (5) and proportionately identical apart from the scale.  Each segment is (as close as done by hand) of equal length, so the shape should theoretically be 4 equal segments, accounting for 25% of the stroke.


                      Animating the End property over 4 seconds for both strokes (and I have added pauses with a Time remap for effect), demonstrates that the line does not animate on linearly.  Most perplexing is that these very similar shapes animate from start to end quite differently.  I would like to know how the percentage translates to stroke length.


                      I'll keep trialling and testing and report back if I figure it out.  Was hoping someone might have encountered this before, or maybe wrote the code behind the Paint Effect.


                      /* EDIT

                           Just copied one of the Brush stroke paths to a Mask and applied the Stroke Effect.  The Stroke Effect animates from 0 to 100% as you would expect, meeting each vertex at the 25%, 50% and 75% markers.  I'll keep digging.




                      • 8. Re: Paint stroke End property interpolation
                        Rick Gerard Adobe Community Professional & MVP

                        The only way to reproduce your problem is to set only 2 keyframes use easing or adjust the timing in the graph editor. Set keyframes for 25% 50% 75% and 100% and the problem goes away. Here's my project.


                        The distance is exactly linear and based on the length of the stroke, not any bezier handles on the paths. Time is dependant on temporal, not spatial interpretation between the keyframes.


                        Screen Shot 2013-09-28 at 5.50.51 AM.png

                        BTW, you can turn on grid or guides and turn on snapp to and make things exact. That's what I did.

                        • 9. Re: Paint stroke End property interpolation
                          notbyhalf Level 1

                          Thanks so much for putting this project together Rick.


                          I must admit, my first reaction was, "No wait, I'm using the Paint Effect, not the Stroke Effect" but when I started copying paths from the Masks in your project file to a new instance of the Paint Effect (shamefully to prove my point), I couldn't replicate the problem either!


                          So I copied your path to Illustrator and my path to Illustrator to compare.  I dare say that snap-to-grid would have saved me much stress, as it appears that my Paint stroke had two vertices in the same place at the starting point.  This appears to have thrown out the stroke length measurement or at least the percentage thereof.  Removing the extra point fixed the timing of my own hand-drawn path.


                          I'm going to see if I can apply what I have learnt here to my script, but I'd like to keep this thread going as I'm sure I'll have some more examples of oversight to run by you again :-)