Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to animate a line in one pixel increments

Engaged ,
Jan 13, 2025 Jan 13, 2025

Hi community.

 

Ive came across a tricky situation in AE.

 

I need to animate a bipolar line, from left to right. (I've uploaded an example, please see the GIF).

first question is, does AE move the Shape line in 1 pixel increments? 

 

Second question is, why does it make that smoothing transition, and not sharp edge like in the example Ive uploaded. Its half pixel smooth, then pixel sharp, then pixel smooth again, then pixel sharp again.

 

Whats the best method to animate a line, perfect pixel by pixel. I need to animate from 0 to 100 a line, and each pixel needs to be perfect without any smoothing on the edges of the line. 

 

Thank you.

 

StefanCargoski_0-1736828950363.pngStefanCargoski_1-1736829138292.png

 

 

The line animations look not smooth in their transitions.

 

https://limewire.com/d/a0db155a-9dd8-4d23-88b8-2cee71b8e5e3#1tr_M9VsiGp_oW5VW46eLvv7RMPr77Nmyv9SUANp...

 

https://filebin.net/w7hxnrslcma5fbtp

TOPICS
How to
665
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 13, 2025 Jan 13, 2025

To animate anything in one-pixel increments, you need to use an expression that converts time to frames and then moves precisely one pixel per frame. This only works for horizontal and vertical movement. Thin curved lines or moving at angles will suffer from anti-aliasing, creating a flickering line. Critical speeds also cause horizontal and vertical edges to judder or look like they are moving with a flicker. The juddering effect is especially evident when trying to do credit rolls. Some effect

...
Translate
Community Expert ,
Jan 13, 2025 Jan 13, 2025

To animate anything in one-pixel increments, you need to use an expression that converts time to frames and then moves precisely one pixel per frame. This only works for horizontal and vertical movement. Thin curved lines or moving at angles will suffer from anti-aliasing, creating a flickering line. Critical speeds also cause horizontal and vertical edges to judder or look like they are moving with a flicker. The juddering effect is especially evident when trying to do credit rolls. Some effects, like trim paths on a shape layer path, work in percentages, so you have to calculate the length, turn that into a percentage, and then ensure that the effects convert the percentage to a whole pixel value. It is also important that you line up thin horizontal and vertical lines with the pixel grid.

 

That said, your comp uses trim paths on a relatively thick horizontal stroked path. The first step is to select the path, then use the Window menu to launch the Create Nulls From Paths.jsx script and choose Points Follow Nulls. Now check the position of the nulls. If your stroke is an even number of pixels thick, the X and Y positions of the nulls should be whole numbers. If the stroke, the X and Y positions must be precisely on a half (.5) pixels. That is the only way to ensure the stroked line precisely lines up with the pixel grid.

 

Now, the easiest way to move the line is to animate the position of the nulls with a simple expression instead of using Trim Paths. Apply this expression to the Right null to make the line grow from the Right to the Left at a constant rate of a specific number of pixels. This will make a line start growing on the 10th Frame and reach a length of 1200 pixels while moving 3 pixels every frame.

 

 

rNull = thisComp.layer("Shape Layer 1: Path 1 [1.1.0]");
strtPos = rNull.position;
endX = 1200,
spd = 6; // number of pixels to move per frame 
StrtTime = 10; // Start on Frame 40;
eTime = endX/spd;
t = timeToFrames();
mov = linear(t, StrtTime, StrtTime + eTime, 0, endX);
[strtPos[0] + mov, strtPos[1]];

 

 

If you want to use Trim Paths, divide 100 by the distance between the nulls and multiply that number by the number of frames you want to move. The expression for the End value of trim paths applied to a horizontal line would look like this:

 

 

rNull = thisComp.layer("Shape Layer 1: Path 1 [1.1.0]");
lNull= thisComp.layer("Shape Layer 1: Path 1 [1.1.1]");
sPos = lNull.position[0];
ePos = rNull.position[0];
dist = 100/(sPos - ePos);
dly = 10; // delay start by 10 frames
t = timeToFrames() - dly;
n = 3; // number of pixels to move per frame
t * dist * n;

 

 

This expression moves the line 3 pixels per frame starting at frame 10 until the line is fully drawn along the X-axis.

 

I hope that gets you started.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 14, 2025 Jan 14, 2025

Thanks for your insight on this one, Ill get to it, and see how much I can get correct. I have a gut feeling I'll be back in 2-3 days if I dont figure this one out.  But if you do happen to know a video lesson tutorial on this method, please do share link, I'd like to see it to understand more about the procedure. 

 

Kind regards.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 14, 2025 Jan 14, 2025
LATEST

Hi Rick.

 

Cant thank you enough! It worked, I needed to tweek the expression with my 1% of knowledge, and got the result Im hoping to deliver. But Ill need one more helpful expression regarding a bipolar line animation epxresison, so Ill repost another question in the forum.

 

Kind regards.



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines