1.彈性表達式
amp = .1;
freq = 2.0;
decay = 2.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){n--;}
}
if (n == 0){ t = 0;}
else{t = time - key(n).time;}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}
else{value}
1. 表達式CreatPath
作用:控制路徑上的點
a = thisComp.layer("a").transform.position; //a空對象的位置
a = thisLayer.fromComp(a); //將a轉化成形狀層thisLayer的坐標,空對象的坐標
b = thisComp.layer("b").transform.position; //b空對象的位置
b = thisLayer.fromComp(b); //將a轉化成形狀層thisLayer的坐標
createPath(points=[a,b],inTangents=[],outTangents=[],is_closed=true)
//createPath是路徑的結構
creatPath函數;
函數的第一項參數points是一個二維數組,也就是數組里還有若干數組,它的每一項代表一個路徑點的坐標;函數讀取points數組里的坐標,從左到右依次連接這些點形成路徑,比如points=([0,0],[100,0],[100,100],[0,100])就是一個正方形;值得一提的是一旦inTangent或者OutTangent不為空,那么這兩個數組就必須有和points數組元素個數相等的元素個數,而且他們的元素的形式和points里的一樣,都是[x,y]形式的坐標,in_closed的值為路徑是否閉合
2. 表達式PointOnPath
作用:把其他圖層放在路徑上
path = thisComp.layer("形狀圖層 1").content("路徑 1").path;b //形狀圖層的路徑
progress = thisComp.layer("形狀圖層 1").content("修剪路徑 1").start/100; //提取路徑的開始位置/100,就是開始坐標
shape_pos = path.pointOnPath(progress); //將形狀層坐標轉化成合成坐標
//comp_ _pos
shapeLayer = thisComp.layer("形狀圖層 1"); //
comp_pos = shapeLayer.toComp(shape_pos)
//返回路徑上占一定百分比的坐標
1.pointOnPath(percentage =0.5, t =time )
pointOnPath字面意思就是點在路徑上,percentage是百分比,0.5就是百分之50 。t是時間(其實這個參數沒太大關系啦不用動)
2.index就是圖層序號,圖層順序從上到下圖層序號從0開始遞增。第一個圖層的index是0,第二個圖層是1 以此類推。
3.pos = linear(index,0,10,0,1)
表示的意思是 index的值從0到10的時候 pos的值對應的從0增加到1。
其實教程這么做也有弊端,那就是只能有10個圖層在路徑上分布,如果想多幾個的話就要把那個10的數字改掉。
pos = linear(index,0,10,0,1);
thisComp.layer("紅色 純色 1").mask("蒙版 1").maskPath.pointOnPath(percentage = pos, t = time);
//pos = linear(index,0,10,0,1); 為了讓圓均勻分布
//thisComp.layer("紅色 純色 1").mask("蒙版 1").maskPath 蒙版路徑
//pointOnPath(percentage = pos, t = time); 點放在路徑上
用法:
在形狀圖層的位置中鏈接到路徑,然后在路徑的后面加上pointOnPath,這樣,形狀圖層就會在路徑上,通過,percentage屬性控制形狀所在的位置,大小是0到1
利用CreatPath做出3D效果
frist = effect("fir")("圖層").index;
end = effect("end")("圖層").index;
pointArr = [];
for(var i=0;i<end-frist+1;i++)
{
var pos = thisComp.layer(frist+1).toComp([0,0,0]);
pos = thisLayer.fromComp(pos);
pointArr.push(pos);
}
close = effect("else")("復選框");
createPath(points = pointArr, inTangents = [], outTangents = [], is_closed = close)
3. 表達式Linear
作用:讓一個數在一個范圍內重新映射
linear(t,tMin,tMax,value1,velue2)
t 代表的是要改變的參數,tMin和tMax是原始范圍,value1和value2是映射的范圍