小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。
忽略父级的旋转(Ignore Parent Rotation)
保持子节点的当前旋转,即使父节点旋转。
value - parent.transform.rotation
忽略父级的缩放(Ignore Parent Scale)
当父层是另一层时,保持层的尺寸。应用于子层的缩放属性。
s = [];
parentScale = parent.transform.scale.value;
for (i = 0; i < parentScale.length; i++){
s[i] = (parentScale[i]== 0) ? 0 : value[i]*100/parentScale[i];
}
s
忽略父级(如果父级还有父级)(Ignore Parent Scale (if parent has parent))
当父层为另一层时,保持该层的尺寸 —— 即使该层有父层。应用于子层的缩放属性。
L = thisLayer;
s = transform.scale.value;
while (L.hasParent){
L = L.parent;
for (i = 0; i < s.length; i++)
s[i] *= 100/L.transform.scale.value[i]
}
s
继承父类的不透明度(Inherit Parent Opacity)
从父层继承不透明度
(hasParent) ? parent.opacity : value;
继承父类的不透明度(可编辑)(Inherit Parent Opacity (editable))
关联不透明度(Invert Opacity)
将不透明度与另一层的不透明度关联。
t = thisComp.layer("Back").transform.opacity // Pickwhip the layer you want to invert
循环进、循环出(Loop In and Out)
在时间上向前和向后循环动画
loopIn() + loopOut() - value;
循环路径关键帧(Loop Path Keyframes)
在形状图层或蒙版的路径属性上无缝循环关键帧
// loop path keyframes. Behaves like loopOut('cycle')
if (numKeys > 1 && time > key(numKeys).time) {
t1 = key(1).time;
t2 = key(numKeys).time;
span = t2 - t1;
delta = time - t2;
t = delta % span;
valueAtTime(t1 + t)
} else {
value
}
循环摆动(Loop a Wiggle)
无缝循环一个 wiggle 表达式(以秒为单位)
frequency = 2; // wiggles per second
amplitude = 40; // amount of pixels to wiggle
secondsToLoop = 3; // time to loop in seconds
// --------
t = time % secondsToLoop;
wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t);
wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop);
linear(t, 0, secondsToLoop, wiggle1, wiggle2)