◆  ◆

Global

全局对象、属性和方法

comp(name)

返回指定名称的合成对象。 

参数 name :字符串。

footage(name)

返回指定名称的素材对象。 

参数 name :字符串。

thisComp

返回表达式所在的合成对象。 

thisProject

返回表达式所在的项目对象。 

thisLayer

返回表达式所在的图层对象。 

//thisLayer 是默认对象,所以其使用是可选的

thisLayer.width 

width

thisProperty

返回表达式所在的属性对象。 

time

返回合成的当前时间(数值),以秒为单位。合成的时间从 0 开始。 

//返回整数时间值

Math.round(time);

//缩放属性的表达式,每秒放大 1 倍

value*time;

colorDepth

返回项目颜色深度值(数值)。

//例如,当每个通道的颜色深度为 8 位时,返回 8

colorDepth

posterizeTime(framesPerSecond)

允许将属性的帧速率设置为低于合成的帧速率。

常用于 wiggle、random、gaussRandom、noise 等方法之前,这些方法通常每帧产生一个随机值,posterizeTime(n) 可限制它们每秒只产生 n 个随机值。

参数 framesPerSecond :数值,指示其余表达式运行的帧速率。

//每秒更新 5 帧的位置属性值

posterizeTime(5);

x = noise(time)*1000;

[value[0]-x,value[1]]

//每秒使用随机值更新一次属性值

posterizeTime(1);  

random()

value

返回当前时间表达式所在的属性的值(数值、数组或对象)。

timeToFrames(t, fps, isDuration)

将时间值 t 转换为帧数(数值)。

参数 t :默认为当前时间:time + thisComp.displayStartTime

参数 fps :帧速率,默认为合成帧速率:1.0 / thisComp.frameDuration

//获得当前时间对应的帧数

timeToFrames()

// 在 25 fps帧速率下 2 秒时对应的帧数

timeToFrames(2,25)

参数 isDuration :默认为 false,表示 t 为当前时间;设为 true 时,指示 t 为时间差。

timeToFrames(2.5,30,true)

framesToTime(frames, fps)

返回在指定的帧速率下指定的帧数 frames 对应的时间(数值)。

参数 fps :默认值与用法同 timeToFrames 方法中的一致。

timeToTimecode(t, timecodeBase, isDuration)

将时间 t 的值转换为表示时间码的字符串。

参数 t 和 isDuration 同 timeToFrames 方法中的一致。

参数 timecodeBase :又称为“时基”,默认为 30 fps。

//获得时基为 25 fps的时间码字符串

timeToTimecode(time,25)

timeToNTSCTimecode(t, ntscDropFrame, isDuration)

将时间 t 转换为表示 NTSC 时间码的字符串。

参数 ntscDropFrame :默认为 false,则结果字符串为 NTSC 未丢帧时间码。为 True 时,则结果字符串为 NTSC 丢帧时间码。

//提示:丢帧时间码各部分之间用 ; 分开

timeToNTSCTimecode(time,true)

timeToFeetAndFrames(t, fps, framesPerFoot, isDuration)

将时间 t 的值转换为表示胶片的英尺数+帧数的字符串。

参数 framesPerFoot :指定一英尺胶片中的帧数。默认为 16,是 35 毫米素材的最常见速率。

其它参数同 timeToFrames 方法。

timeToCurrentFormat(t, fps, isDuration)

将时间 t 的值转换为采用当前项目设置显示时间的格式字符串。

参数同 timeToFrames 方法。