(Page 1 of 3 pages for this article  1 2 3 >)

Sunday, November 28, 2010

Filed under: Motion GraphicsVisual Effects

Deeper Modes of Expression, Part 12: Expressive Text

Chris Meyer | 11/28

In this final installment in our series, we’ll demonstrate several ways to manipulate numbers and text using expressions.

Finally, we’d like to demonstrate ways to use expressions to manipulate text created with the new Type tool. We’ll show how to display time and parameter values as text, both for diagnostic purposes and to create graphical elements. On the second page we’ll show to how to manipulate strings of text, including using the Buzz Words animation preset to cycle through words in a list. Then on the last page we’ll talk about the Expression Selector to animate text created with the Type tool.

We admittedly will just scratch the surface here; you can then go much further employing standard JavaScript text “string” methods such as toUpperCase (although you cannot use JavaScript text formatting methods such as .bold and .fontsize on Source Text – you will just see the resulting HTML code, rather than re-style the After Effects text).

Type Tool Overview

To use expressions with text, you need to have some familiarity with the Type tool (covered in Chapter 21 of the latest edition of our book Creating Motion Graphics with After Effects). As a starting point, you will need to create a text layer: Press Command+T on Mac (Control+T on Windows) to select the Type tool; adjust the Character and Paragraph panels for the font type, color, and size you want to use; click in the Comp panel; and type away. You can type anything right now for your text; we’ll be replacing it with expressions. Press Enter to accept what you’ve typed, and press V to revert to the normal Selection tool. (You can select the text layer any time later and change its formatting with the Character and Paragraph panels.)

Then twirl open the parameters for the text layer you’ve created in the Timeline panel, exposing Source Text (as shown below), which most of our examples here will be for. You can replace Source Text with a one-dimensional number, or with a “string of characters” (which need to be inside quotes to be recognized). If After Effects cannot process what you’ve created with your expression, it will display the word “undefined” in the Comp panel, or in some cases it will display the HTML code for what the JavaScript is trying to create.

Numbers to Text

One of the easiest things to do is have After Effects display a number you’ve generated, such as a Position or Rotation value. Aside from creating graphic displays, this provides an excellent tool for debugging expressions: It lets you display a value or string you are working on to see what your expression is really doing inside.

In our example below, we Option+clicked (Alt+clicked) on Source Text and dragged its pick whip to the value for Y Position. (Note that Source Text has one dimension, where Position has two dimensions – so you need to explicitly pick which dimension you want. See the third installment on arrays for a refresher course as to how and why.) Scrub the time indicator while watching the Position value in the Timeline panel and the result in the Comp panel. After Effects keeps a lot of internal precision when calculating values – and you get to see all that precision displayed, as seen below:

The purple value on the left shows the full numeric precision After Effects carries internally for Position; the green value on the right is the result of rounding it down to one decimal place.

Quite often, you want to display only some of this precision. When you’re using a plug-in like Effect > Text > Numbers, you get to choose how many decimal points you want to see. With expressions, you need to do a little more work: You need to multiply the value to get all the digits you want to keep to the left of the decimal point, use the Math.round method (as discussed in the first installment on useful math expressions) to get rid of the leftover digits, then divide the result by the same amount to move the original numbers back to their correct place to the right of the decimal point. To display just one digit to the left of the decimal point for Y Position, we needed to multiply the original value by 10, round it, then divide by 10, yielding the expression Math.round(position[1]*10) / 10.

For numeric displays, it is often good to use a font that keeps the same spacing per character, such as Courier or Monaco. Using fonts with proportional spacing will result in the displayed text changing width as the number being displayed changes.

Timecode

After Effects includes as set of expression methods that can convert the current time in a comp to either a timecode or a feet+frame format that Source Text can display, as shown at left. These expression methods include:

timeToTimecode, which converts time (in seconds) to SMPTE timecode

timeToNTSCTimecode, with switches for Drop Frame and Non-Drop timecode

timeToFeetAndFrames, which converts time to this common film ¬display format

timeToCurrentFormat, which uses the format chosen in File >
Project Settings > Display Style

As with many advanced methods, there are a variable number of values that may be contained inside parentheses that follow the method’s name. You must include at least the first one, which is time. If you use the word time – as in timeToTimecode(time) – After Effects will use the comp’s current time. (All of the After Effects time conversion methods ignore the Start Timecode or Frame value in Composition Settings; this setting is used only for display purposes in the Comp and Timeline panels. Inside expressions, the first frame of the comp always equals 0.0 seconds, and frame number 0.)

In the methods timeToFeetAndFrames() and timeToCurrentFormat(), the second value is the frames per second (fps) rate; if you don’t enter it, After Effects will use the comp’s frame rate. In timeToTimecode(), the second value is the timecode’s timebase (24, 25, or 30); if you don’t enter it, After Effects will use 30 (not the setting in File > Project Settings). In timeToNTSCTimecode(), the second value asks whether you want to use the Drop Frame counting method: Enter true if you do, and false if you want to use Non-Drop counting (the default).

The method timeToFeetAndFrames() has a third value which represents the number of frames in a foot of film; it defaults to the 35mm value of 16. Finally, the last number for all of these methods helps After Effects decide how to round numbers: If it might be negative, enter true so After Effects will always round away from 0; don’t bother entering it if the value displayed is always a positive number.

The timecode methods, among other things, can be used to create your own “burn in” timecode or feet+frame numbers for footage – or just cool numeric readouts.

Note that in earlier versions, After Effects could sometimes get in a state where the result generated by timeToNTSCTimecode would go awry just before the one hour mark. This is apparently fixed now. If you still manage to experience this problem, open the Comp settings, change the frame rate to 30 fps, click OK, open the Comp settings again, and change it back to 29.97 fps.

next page: managing strings of text

(Page 1 of 3 pages for this article  1 2 3 >)

               



You must be registered to comment. This is an effort to reduce spam. Please REGISTER HERE.

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:




After Effects Apprentice Free Video: Rendering a 4:3 Center Cut Movie from a 16:9 Composition
After Effects Apprentice Free Video: Using Parenting to Animate Layers as a Unit
After Effects Apprentice Free Video: Working with Nested 3D Compositions
After Effects Apprentice Free Video: Copying Paths from Illustrator to After Effects
After Effects CS6 Tutorial: Exporting 3D Camera Tracker Data to Cinema 4D
After Effects CS6 Tutorial: Targeting Properties in the new Ray-Traced 3D Engine
After Effects CS6 (P)Review
After Effects Apprentice Free Video: Exploring Shape Effects
After Effects Apprentice Free Video: Drawing Parametric Shapes
After Effects Apprentice Free Video: The Puppet Starch Tool
After Effects Apprentice Free Video: Eraser Tool Modes
After Effects Apprentice Free Video: Tracking with mochaAE
After Effects Apprentice Free Video: Performing a Motion Track
After Effects Apprentice Free Video: Creating 3D Objects using Adobe Repoussé
After Effects Apprentice Free Video: Understanding Axis Modes
Using After Effects as an Advanced Titler for Premiere Pro
After Effects Apprentice Free Video: Creating an Orbit Camera Rig
CMG Hidden Gems: Chapter 45 – What’s Your Preference?
CMG Hidden Gems: Chapter 44 – Prerendering and Proxies
CMG Hidden Gems: Chapter 43 – Advanced Rendering
CMG Hidden Gems: Chapter 42 – Render Queue
CMG Hidden Gems: Chapter 41 – Video Issues
CMG Hidden Gems: Chapter 40B – 3D Channel Effects
CMG Hidden Gems: Chapter 40 – Integrating with 3D Applications
CMG Hidden Gems: Chapter 39 – Integration 101
After Effects Apprentice Free Video: Multiple Playback Speeds
CMG Hidden Gems: Chapter 38 – Import and Interpret
CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters
CMG Hidden Gems: Chapter 37 – Expressions
CMG Hidden Gems: Chapter 36B – Audio Effects







After Effects Apprentice Free Video: Working with Nested 3D Compositions

Chris and Trish Meyer | 05/07

How you can be two places at once inside After Effects

As we mentioned awhile back, we’ve been busy the past year and a half creating an extensive, multi-course video training…

Expression Shorts - loop

David Torno | 05/06

Learn how the loop expressions work.

image

Looping is a very common task in our industry and is mostly associated with video footage of some…

An elegant iPhone timecode calculator

Scott Simmons | 05/02

UPDATE: ALL THE FREE CODES ARE GONE Panoptik has created a very good looking, easy to use timecode calculator

image

Many, many years ago I wondered if we were going to get some good filmmaking…

After Effects Apprentice Free Video: Copying Paths from Illustrator to After Effects

Chris and Trish Meyer | 05/01

Revealing Illustrator paths requires a few intermediate steps, involving After Effects masks and effects.

Buried in the shuffle over the announcement of After Effects CS6 is that we concluded the video training series for our book After…

To be considered for listing, contact pr (at) provideocoalition (dot) com


Copyright © 2012, HD Expo, LLC a division of Diversified Business Communications. DBA Createasphere

All rights reserved. HD EXPO, High Def EXPO, Createasphere, E-Tech, Entertainment Technology Exposition, 3D Production Workshop, VariCamp, P2 Camp, ColorCamp 101, and Lighting, Filters & Gels for HD are all trademarks of HD Expo, LLC.

Terms of Use  |  Privacy Policy

Check PageRank