文章目录
1.算法程序
- 1.算法程序
- 2.文本转执行
- 3.作者答疑
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
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?