您当前的位置: 首页 > 

插件开发

暂无认证

  • 1浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AfterEffect(AE)插件-常规功能开发-放大缩小图层-js脚本开发-AE插件

插件开发 发布时间:2022-03-23 08:21:50 ,浏览量:1

文章目录
    • 1.算法程序
    • 2.文本转执行
    • 3.作者答疑

1.算法程序

  AfterEffect(AE)插件是Adobe公司开发的特效制作软件,稳定快速的功能和特效,在视频制作领域使用非常广泛,本文向大家介绍如何在项目里进行放大缩小图层功能。源代码如下所示:

{
	// Scale Selected Layers.jsx
	// 
	// This script scales the selected layers within the active comp.
	//
	// First, it prompts the user for a scale_factor.
	// Next, it scales all selected layers, including cameras.
	
	function ScaleSelectedLayers(thisObj)
	{
		var scriptName = "Scale Selected Layers";
		
		// This variable stores the scale_factor.
		var scale_factor = 1.0;
		var scale_about_center = true;
		
		
		//
		// This function is called when the user clicks the "Scale about Upper Left" button
		//
		function onCornerButtonClick()
		{
			scale_about_center = false;
		}
		
		
		//
		// This function is called when the user clicks the "Scale about Upper Left" button
		//
		function onCenterButtonClick()
		{
			scale_about_center = true;
		}
		
		
		//
		// This function is called when the user enters text for the scale.
		//
		function on_textInput_changed()
		{
			// Set the scale_factor based on the text.
			var value = this.text;
			if (isNaN(value)) {
				alert(value + " is not a number. Please enter a number.", scriptName);
			} else {
				scale_factor = value;
			}
		}
		
		
		function onScaleClick()
		{
			var activeItem = app.project.activeItem;
			if ((activeItem == null) || !(activeItem instanceof CompItem)) {
				alert("Please select or open a composition first.", scriptName);
			} else {
				var selectedLayers = activeItem.selectedLayers;
				if (activeItem.selectedLayers.length == 0) {
					alert("Please select at least one layer in the active comp first.", scriptName);
				} else {
					// Validate the input field, in case the user didn't defocus it first (which often can be the case).
					this.parent.parent.optsRow.text_input.notify("onChange");
					
					var activeComp = activeItem;
					
					// By bracketing the operations with begin/end undo group, we can 
					// undo the whole script with one undo operation.
					app.beginUndoGroup(scriptName);
					
					// Create a null 3D layer.
					var null3DLayer = activeItem.layers.addNull();
					null3DLayer.threeDLayer = true;
					
					// Set its position to (0,0,0).
					if (scale_about_center) {
						null3DLayer.position.setValue([activeComp.width * 0.5, activeComp.height * 0.5,0]);
					} else {
						null3DLayer.position.setValue([0, 0, 0]);
					}
					
					// Set null3DLayer as parent of all layers that don't have parents.  
					makeParentLayerOfUnparentedInArray(selectedLayers, null3DLayer);
					
					// Then for all cameras, scale the Zoom parameter proportionately.
					scaleCameraZoomsInArray(selectedLayers, scale_factor);
					
					// Set the scale of the super parent null3DLayer proportionately.
					var superParentScale = null3DLayer.scale.value;
					superParentScale[0] = superParentScale[0] * scale_factor;
					superParentScale[1] = superParentScale[1] * scale_factor;
					superParentScale[2] = superParentScale[2] * scale_factor;
					null3DLayer.scale.setValue(superParentScale);
					
					// Delete the super parent null3DLayer with dejumping enabled.
					null3DLayer.remove();
					
					// Everything we just did changed the selection. Reselect those
					// same layers again.
					for (var i = 0; i             
关注
打赏
1665481431
查看更多评论
0.9633s