ae expression cheat sheet
1.0.0
目的 | 描述 | 例子 |
---|---|---|
thisComp | 当前组成 | thisComp; |
thisLayer | 当前层 | thisLayer.transform.scale[1]; |
thisProperty | 当前属性表达式应用。 | thisProperty[1]; |
time | 当前的时间代码在光标位置在几秒钟内。 | "Seconds: " + time; |
value | 与当前属性相关的当前价值。 | value + "_TEST"; |
目的 | 描述 | 例子 |
---|---|---|
colorDepth | 每个像素的项目颜色深度。 | colorDepth; |
功能 | 描述 |
---|---|
layer(index || number) | 返回图层,轻或相机对象。 |
layer(layer, relIndex) | 用相对索引返回给定层的对象。 |
功能 | 描述 | 例子 |
---|---|---|
framesToTime(frames, fps) | 将帧转换为秒钟。 | framesToTime(50, 1.0 / thisComp.frameDuration); |
timeToCurrentFormat(t, fps, isDuration) | 将时间代码转换为当前项目设置显示格式。 | |
timeToFeetAndFrames(t, fps, framesPerFoot, isDuration) | 将时间代码转换为脚和帧格式。 | |
timeToFrames(t, fps, isDuration) | 将时间代码转换为帧。 | |
timeToNTSCTimecode(t, ntscDropFrame, isDuration) | 在有或没有下降框架的情况下,将时间代码转换为NTSC时机。 | |
timeToTimecode(t, timecodeBase, isDuration) | 使用给定的时间表将时间代码转换为其他时间码。 |
功能 | 描述 | 例子 |
---|---|---|
comp(name) | 找到带有给定名称的开放构图。 | comp("Comp 1"); |
footage(name) | 找到带有名称的项目录像。 | footage("RedHarring.png"); |
您有:
你想要:
解决方案:
假设您的形状层具有矩形形状。
将矩形层的父将其设置为文本层,这将使定位相对于文本层的定位。
在矩形路径的大小属性中添加以下表达式
var textLayer = thisComp . layer ( "Text Layer 1" ) ;
var textRect = textLayer . sourceRectAtTime ( time - textLayer . inPoint , true ) ;
// set size of rectangle path to text rectangle's width and height
[ textRect . width , textRect . height ] ;
这将把矩形的大小设置为文本的大小。当有多行时,它需要所有线路的全尺寸。
var rectPath = content ( "Rectangle 1" ) . content ( "Rectangle Path 1" ) ;
var x = rectPath . size [ 0 ] ;
var y = rectPath . size [ 1 ] ;
// set position of rectangle path to text rectangle's width and height
[ x / 2 , - ( y / 2 ) ] ;
这将矩形路径的左下位置设置为层的左上。文本层总是在文本第一行的左下方都有其锚点。这将使计算更容易执行。
var textLayer = thisComp . layer ( "Text Layer 1" ) ;
var textRect = textLayer . sourceRectAtTime ( time - textLayer . inPoint , true ) ;
[ textLayer . transform . position [ 0 ] + textRect . left ,
textLayer . transform . position [ 1 ] + textRect . top + textRect . height ] ;
这将矩形层的位置设置为文本的位置。添加矩形尺寸的原因是因为字体渲染可能会导致首字母不在位置上的几个像素。添加矩形坐标将弥补这一点。
问题:
您有:
你想要:
将水平抖动添加到视频中,使其看起来像50 Hz的交织在一起。
解决方案:
[ transform . position [ 0 ] , transform . position [ 1 ] + ( ( timeToFrames ( time ) % 2 ) * 2 ) ]
问题:
抖动太重了,您可以通过删除表达式中的乘法来解决此问题
[ transform . position [ 0 ] , transform . position [ 1 ] + ( timeToFrames ( time ) % 2 ) ]
甚至多次又一半,以获得非常微妙的摇动。
[ transform . position [ 0 ] , transform . position [ 1 ] + ( ( timeToFrames ( time ) % 2 ) * 0.5 ) ]
文本需要垂直以中心为中心。将以下表达式添加到文本层的转换。位置属性
S = thisLayer ;
x = transform . position [ 0 ] ;
y = transform . position [ 1 ] ;
rect = S . sourceRectAtTime ( time , false ) ;
y_offset = rect . height / 2 ;
[ x , y - y_offset ]