Ae 核心表达式及用法(05):路径相关

createPath(points, inTangents, outTangents, is_closed) 

根据一组点和切线创建路径对象。

例:使得物件出现在每一个路径点上。

先为”路径“(形状)图层的路径属性添加表达式。

//先将“路径”图层的锚点、位置属性均设为 [0,0]。并为此图层添加滑块控制。
//滑块控制中的滑块设置了关键帧
controler = effect("滑块控制")("滑块").value;
steps = 20;
size = 20;
newPoints = [];
//生成叶序曲线点
for (t=1;t<steps;t++){
  a = t*size*-1;
  b = controler*0.1*(2*Math.PI*(steps-t));
  x = Math.cos(b)*a+thisComp.width/2;
  y = Math.sin(b)*a+thisComp.height/2;
  newPoints.push([x,y]); // 向newPoints 添加一个新元素
}


createPath(points = newPoints, inTangents = [], outTangents = [], isClosed = false);

为物件图层添加表达式后,复制多份(路径点数目)物件图层。

//物件图层位置表达式。根据“路径”形状图层创建的路径点来决定位置。
thisComp.layer("路径").content("路径 1").path.points()[index-1];

9c8074df6302171cad25b8208cab2252.gif

points(t)

获取路径上所有点的 x、y 坐标。

例:先绘制一个矩形形状,并转换为贝塞尔曲线路径。再添加一个路径属性,并为路径 2 的路径属性添加表达式。

//路径1是一个矩形贝塞尔曲线路径。此处为路径2的路径属性表达式
//获得当前路径在上一级对象中的序号
indexProperty = thisProperty.propertyGroup(1).propertyIndex;
//获得上一层的路径
mask1 = content("矩形 1").content(indexProperty - 1).path;
//获得变化的四个点。
point1 = linear(time,0,2,mask1.points()[0],mask1.points()[1]);
point2 = linear(time,0,2,mask1.points()[1],mask1.points()[2]);
point3 = linear(time,0,2,mask1.points()[2],mask1.points()[3]);
point4 = linear(time,0,2,mask1.points()[3],mask1.points()[0]);
//创建路径
createPath(points = [point1, point2, point3, point4], inTangents = [], outTangents = [], isClosed = true)

7b254508105c35b26388c3cb459dc7da.gif

pointOnPath(percentage, t) 

获取路径上任意点的 x、y 坐标。

参数 percentage:路径点在路径弧长的百分比。

参数 t:默认为 time,指定采样到路径的时间。

//"路径形状"图层路径表达式。先在“路径”纯色图层上设置蒙版路径关键帧。
thisComp.layer("路径").mask("蒙版 1").maskPath
//"物件"图层的位置表达式。
pos = linear(index,1,10,0,1);
thisComp.layer("路径").mask("蒙版 1").maskPath.pointOnPath(pos, t = time);

0eb79dce211039b2635a1bffb3f9009f.gif

类似的第二个例子,让形状图层的椭圆路径绕着纯色图层的蒙版路径运动。

//复制的椭圆路径后可产生位置上的偏移
pathIndex = thisProperty.propertyGroup(1).propertyIndex;
newTime = time + ((pathIndex-1)*-0.05);
// 椭圆路径的位置属性表达式。2 秒钟绕蒙版路径转一圈
thisComp.layer("纯色(蒙版路径)").mask("蒙版 1").maskPath.pointOnPath(newTime/2%1)

e47b8029c6931182ad1bdffbdb631e9e.gif

11a2952d49aabee68447c0b60f9f9adf.png

“有钱的捧个钱场,好看的点下在看”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值