beautypg.com

Adobe After Effects CS4 User Manual

Page 677

background image

671

USING AFTER EFFECTS CS4

Expressions

Last updated 12/21/2009

Returns true if the Video switch

is on for the layer; false otherwise.

sampleImage(point, radius = [.5, .5], postEffect=true, t=time)

Return type: Array [4].

Argument type: point is an Array [2], radius is an Array [2], postEffect is a Boolean, and t is a Number.

Samples the color and alpha channel values of a layer and returns the average alpha-weighted value of the pixels within
the specified distance of the point as an array: [red, green, blue, alpha]. If postEffect is true, the sampled values are for
the layer after masks and effects on that layer have been rendered; if postEffect is false, the sampled values are for the
layer before masks and effects have been rendered. The input value point is in layer space; the point [0,0] is the center
of the top-left pixel in the layer. The input value radius specifies the horizontal and vertical distance from the sample
center to the edges of the sampled rectangle. The default value samples one pixel.

Note: The

postEffect

parameter refers to effects applied directly to the layer, not to effects applied indirectly, such as

with an adjustment layer.

This example samples a rectangle 4 pixels wide and 3 pixels high, centered around a point 100 pixels down and to the
right of the upper-left corner of the layer:

thisComp.layer(1).sampleImage([100, 100], [2, 1.5])

Dan Ebberts provides an example of how to use the

sampleImage

method on his

MotionScript website

.

The

AE Enhancers forum

provides an expression that uses the

sampleImage

method to measure a text layer or shape

layer and determine its effective bounding box.

Todd Kopriva provides instructions for using the

sampleImage

method and the Point Control effect to monitor colors

for a specified point during color correction on his

After Effects Region of Interest blog

.

Layer Properties attributes and methods (expression reference)

When you add masks, effects, paint, or text to a layer, After Effects adds new properties to the Timeline panel. There
are too many of these properties to list here, so use the pick whip to learn the syntax for referring to them in your
expressions.

anchorPoint

Return type: Property [2 or 3].

Returns the anchor point value of the layer in the coordinate system of the layer (layer space).

position

Return type: Property [2 or 3].

Returns the position value of the layer, in world space if the layer has no parent. If the layer has a parent, returns the
position value of the layer in the coordinate system of the parent layer (in the layer space of the parent layer).

scale

Return type: Property [2 or 3].

Returns the scale value of the layer, expressed as a percentage.

rotation

Return type: Property.

Returns the rotation value of the layer in degrees. For a 3D layer, it returns the z rotation value in degrees.

opacity

Return type: Property.

Returns the opacity value for the layer, expressed as a percentage.

audioLevels

Return type: Property [2].

Returns the value of the Audio Levels property of the layer, in decibels. This value is a 2D value; the first value
represents the left audio channel, and the second value represents the right. The value is not the amplitude of the audio
track of the source material. Instead, it is the value of the Audio Levels property, which may be affected by keyframes.

This manual is related to the following products: