Site icon ProVideo Coalition

Fixing soft edges & number counters with automatic rounding

A few years ago, Stu Maschwitz noted the utility of the Math.round method, which rounds a number to the nearest integer. If you're repositioning or animating an object in AE, you'll often run into AE's subpixel positioning in Best Quality, which as noted long before expressions were a feature by Trish Meyer as the source of bad renders with lossy formats. But you can use an expression to force rounding on scale/position to whole numbers, in order to avoid softening on anti-aliased text or other layers. It's much easier to use that than to adjust entries by hand, and its utility goes further.

The problem was demoed earlier by Chris Silich in an article After Effects Expression: Snapping objects to whole pixels. To make fixes easier, there's also a 2012 preset from Motionworks in Snapping to Whole Pixels. The same method was used in After Effects Text As A Number Variable, a free project by Brian Charles.

Here's the demo of the problem from Chris Silich:


 

The Math.round expression function and similar solutions (Math.floor rounds down, Math.ceil rounds up) were discussed previously many times in various forums, but a broad peek at various wrinkles can be found in Deeper Modes of Expression, Part 1: Useful Math Expressions by Chris and Trish Meyer. You can find the full series in their book Creating Motion Graphics and through Deeper Modes of Expression: The Index, a linked list of 12 installments in their series on expressions in After Effects.

Math.round is used in a variety of ways; for example, Daniel Bachler showed how to use it with the Timewarp effect in High quality retiming from 30 to 25 fps using After Effects. You can find another use of Math.round for generating numbers in Red Giant Episode 26: Score! Working with Numeric Text. By the way, James Buckhouse provided a free AEP of an After Effects counter rising to a million.


Among the several overview resources on expressions is Harry Frank's 2007 video training, After Effects Expressions. Lesson 4 of this now free set dealt with numbers, rounding, and decimals with Math.round. Here's Red Giant #26, which added a section on triggering at layer markers:

Nick Khoo had another take on numbers earlier in 2012 with Animating numbers counting up in After Effects, as did Evan Abrams in The Time Script. More recently, there was another reminder from Mikey Borup in After Effects Shape Layers tutorial.




 

Update: For something not completely different (not using Math.round), see Random numbers transition to text by Mikey Borup:

Exit mobile version