【迷你通信手表】用到的編程表達(dá)式
1、秒針表達(dá)式
var t=time;
if(Math.floor(t)%60>9)? ? ? ? //取整表達(dá)式Math.floor(t)? ? ? t代表時(shí)間,單位秒? ? ?整數(shù)除以60的余數(shù)大于9
Math.floor(t)%60;? ? ? ? ? ? ? ? //則得到這個(gè)余數(shù)
else "0"+Math.floor(t)%60? ?//反之則得到 數(shù)字0+這個(gè)余數(shù)
2、分針表達(dá)式
var t=time;
if(Math.floor(t/60)%60>9)? ? //同上,區(qū)別在于t/60,時(shí)間t變慢60倍,即是分鐘
Math.floor(t/60)%60;
else "0"+Math.floor(t/60)%60
3、圖形大小隨透明度變化的位置表達(dá)式
P = value + thisComp.layer("contral").transform.position;? ?// value 原先的值,這點(diǎn)指位置數(shù)組? ?加上? ?圖層名字是“contral”的位置數(shù)組參數(shù)
target = thisComp.layer("漸變");? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//“漸變”圖層賦予變量target
x = 1-(target.sampleImage(P,[0.5,0.5]/2,true,time)[0]);? ? ? ? ?//? target.sampleImage(P,[0.5,0.5]/2,true,time)? ?對”漸變“圖層里P位置進(jìn)行采樣? ? [0] 采樣結(jié)果數(shù)組里選取第一個(gè)數(shù)值?
point1 = thisComp.layer("center").position;? ? ? ? ? ? ? ? ? ? ? ? ?// 圖層“center”中心點(diǎn)的位置,即屏幕中心的位置
point2 = P;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 圖標(biāo)變化后的位置
delta =sub(point1,point2);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 兩個(gè)位置求差,即圖標(biāo)距離屏幕中心點(diǎn)的位置
X = delta[0];? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)定X為delta X軸的參數(shù) )(計(jì)算機(jī)是二進(jìn)制,0和1,代表兩個(gè)狀態(tài)下的數(shù)值)
Y = delta[1];? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)定Y為delta Y軸的參數(shù)
[P[0]+((X*0.15)*x),P[1]+((Y*0.1)*x)]? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // P[0] 圖標(biāo)變化后的位置X軸參數(shù)? ?P[1] 圖標(biāo)變化后的位置Y軸參數(shù)? ? 最終輸出位置
4、圖形大小隨透明度變化的縮放表達(dá)式
a = thisComp.layer("漸變");? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//名字是"漸變"的圖層賦予變量a
x = a.sampleImage(transform.position,[0.5,0.5],true,time)[0]*100;? //? sample Image() 采樣表達(dá)式? ? ?a.sampleImage() 采樣a圖層? ?transform.position 文本圖層的位置作為采樣圖層的位置? ? [0.5,0.5]? 每次采樣范圍,按長0.5個(gè)像素,寬0.5個(gè)像素采樣? ? ?true 計(jì)算蒙版和效果所產(chǎn)生的影響? ? time 采樣時(shí)間? [0]選取顏色參數(shù)rgb和a四個(gè)數(shù)字的數(shù)組中的第一個(gè)數(shù)字? ?*100 本來輸出的數(shù)值是0到1之間的,需要縮放百分比參數(shù)是0到100,所以要擴(kuò)大100倍??
y =linear(x,0,100,0,100);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //linear() 把數(shù)值重新映射的函數(shù)? 第一個(gè)參數(shù)x是要映射的屬性? 第二個(gè)參數(shù)0和第三個(gè)參數(shù)100是映射前的屬性? 第四個(gè)參數(shù)0和第五個(gè)100是映射后的屬性? 之前縮放數(shù)值變過就改映射后的屬性
[y,y]? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //最終輸出的數(shù)組