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 ]