表达式用法案例.docx

上传人:博****1 文档编号:562524084 上传时间:2023-05-17 格式:DOCX 页数:6 大小:16.56KB
返回 下载 相关 举报
表达式用法案例.docx_第1页
第1页 / 共6页
表达式用法案例.docx_第2页
第2页 / 共6页
表达式用法案例.docx_第3页
第3页 / 共6页
表达式用法案例.docx_第4页
第4页 / 共6页
表达式用法案例.docx_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《表达式用法案例.docx》由会员分享,可在线阅读,更多相关《表达式用法案例.docx(6页珍藏版)》请在金锄头文库上搜索。

1、一、创建固态层,灯光,摄像机1.空白层的添加:(只复制文字下的一段就好了)if(app.project.activeItem) app.project.activeItem.layers.addNull();2.固态层的添加:(对应参数就不再一一说明了,想了解的自行寻找.)myComp = app.project.activeItemif(app.project.activeItem) app.project.activeItem.layers.addSolid(Math.random()*.2+.5,Math.random()*.2+.5,Math.random()*.2+.5, Quick

2、 Solid,myComp.width,myComp.height,1);3.摄像机的添加:if(app.project.activeItem) app.project.activeItem.layers.addCamera(Camera,0.5*myComp.width,0.5*myComp.height);4.灯光的添加:if(app.project.activeItem) app.project.activeItem.layers.addLight(Light,0.5*myComp.width,0.5*myComp.height);5.调节层的添加:AdjustmentLayer=myC

3、omp.layers.addSolid(1,1,1,AdjustmentLayer,myComp.width,myComp.height,1); AdjustmentLayer.adjustmentLayer=true6.文字层的添加:(感觉这个没必要,方便大家一起写出来)if(app.project.activeItem) app.project.activeItem.layers.addText();7.形状层的添加:(同上)if(app.project.activeItem) app.project.activeItem.layers.addShape();8.工程文件夹项目创建var

4、mov=app.project.items.addFolder(001-视频 );var pic=app.project.items.addFolder(002-图片 );var picyy=app.project.items.addFolder(AI );var picdy=app.project.items.addFolder(PSD );var picxl=app.project.items.addFolder(序列 );picyy.parentFolder =pic;picdy.parentFolder =pic;picxl.parentFolder =pic;var sound=ap

5、p.project.items.addFolder(003-声音 );var soundyx=app.project.items.addFolder(音效 );var soundbjy=app.project.items.addFolder(背景音 );var soundpb=app.project.items.addFolder(旁白 );soundyx.parentFolder =sound;soundbjy.parentFolder =sound;soundpb.parentFolder =sound;var comp=app.project.items.addFolder(004-合成

6、 );var other=app.project.items.addFolder(005-其他 ); +二.特殊表达式的添加弹性表达式续 JAVASCRIPT类型添加 (复制虚线下内容到编辑框)=/万能弹性表达式添加器/*n=0; N其实是用来记录关键帧序号的,这个变量很重要 if (numKeys 0) 判断关键帧个数是否大于0,如果是执行中内容 n = nearestKey(time).index 取靠近时间线的那个关键帧的序号,这里要注意取得的关键帧有可能是时间线前的最后一个,也可能是时间线后的第一个,所以才有下一句的IF判断。 if (key(n).time time)n-; 如果取得

7、的关键帧是时间线后面第一个,则N的序号减1,这样就保证里N永远代表的是时间线前的最后一个关键帧。 if (n = 0) t = 0; 如果没有关键帧(N=0)时,T=0。T是一个频率改变因数,也是一个阻力改变的因数。 elset = time - key(n).time; 如果N不为0,那么T就等于时间线与其之前最后一个关键帧的时间的差,也就是说时间线离这个关键帧越远T就越大。 if (n 0) 当有关键帧,也就是说有动画的时候执行里的内容,前面那些句都是铺垫,这个大括号里的才是正戏。 v = velocityAtTime(key(n).time - thisComp.frameDuratio

8、n/10); velocityAtTime()这个函数是求在某一时刻对象的速度,AE里面叫关键帧数率,单位是像素/秒,怎么理解这个呢?其实就是你在做对象位移动画时,关键帧时刻对象相对屏幕的瞬时速度,说屏幕有点不准确,应该说对象所在合成。 *我不明白了地方也来了,thisComp.frameDuration 的解释是返回画面的持续时间 thisComp.frameDuration/10 这个是不能去掉的,不然会出现很奇怪的弹动现象。但是减号后面也不一定要是 thisComp.frameDuration/10 ,只要是一个非常小的数就可以,主要可能是取关键帧前很短一个时刻的速度,就算是用F9平滑关

9、键帧,弹动也能发生效果。用 thisComp.frameDuration/10 只是因为它足够小,因为是帧率时间的1/10value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t); value+ 这个是在原来值的基础上做弹性设置的,这么写的好处是无论你把这段表达式放在2D还是3D图层中都可以起作用,不用x,y,z这么写是确保动画在三个轴向上的运动都会有弹性动画。 v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t); V是对象关键帧的瞬时速度,这个变量是作为一个振幅变量的补充,这样更符合

10、物理现象,当速度越大振幅就越大。当对象的速度是0时,那弹性表达式结果也为0。 T在Math.sin()中是作为频率的补充,作用是时间线离关键帧越远,值越大频率越快,这样比较符合物理规律。 T在Math.exp()中试阻力指数,作用是时间线离关键帧越远,值越大阻力越大,最后让弹动归于平静。 elsevalue 如果没有关键帧,原来值保持不变.*/var thisComp = app.project.activeItem;if (thisComp = null) | !(thisComp instanceof CompItem) alert(Please selected comp first !

11、); else if (thisComp.selectedLayers.length1) alert(Please selected layer first !); else var sl= thisComp.selectedLayers0;if (sl.selectedProperties.length0) n+n = nearestKey(time).index;n+if (key(n).timetime) n+n-;n+n+n+if (n = 0) n+t = 0;n+ else n+t = time-key(n).time;n+n+if (n0) n+v = velocityAtTim

12、e(key(n).time-thisComp.frameDuration/10);n+value+v*amp/100*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);n+ else n+value;n+;pop=sl.selectedProperties0;if(pop.canSetExpression=false)alert(该属性无法添加弹性表达式!);elsepop.expression=exp;续 Animation presets类型添加提取脚本核心内容为.=编号=thisComp.layer(格子铺 1).index-index;弹力=th

13、isComp.layer(Paste Here).effect(弹力)(1);弹性=thisComp.layer(Paste Here).effect(弹性)(1)/10;起始插值=thisComp.layer(Paste Here).effect(起始插值)(1)/100;最高峰值时间=thisComp.layer(Paste Here).effect(速度)(1)/100;阻力=thisComp.layer(Paste Here).effect(阻力)(1)/10;s=thisComp.layer(格子铺 1).transform.scale;if(最高峰值时间=0)g=1elseg=最高峰值时间;q=起始插值%g;t=最高峰值时间-q;var1=linear(time,编号*t,编号*t+最高峰值时间,0,0,s);if(time编号*t+最高峰值时间)r=0elser=1;if(time-(编号*t+最高峰值时间)0)x=0elsex=time-(编号*t+最高峰值时间);z=Math.sin(弹性*(time-(编号*t+最高峰值时

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号