文章目录
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
关注
打赏
热门博文
- Adobe illustrator插件开发-SPInterfaceSuite-插件A向插件B传递消息-插件通信-AI插件开发
- javascript-ztree-树形控件-初始化-加载节点数据-节点数据获取
- Adobe illustrator插件开发-坐标系统-AIHardSoftSuite-画板坐标-页面坐标-AI插件开发
- Adobe illustrator插件开发-AIUIDUtilsSuite-AIUIDPoolSuite-AIUIDSuite-AIUIDREFSuite-Art唯一标识符与索引-AI插件开发
- C++-逆向分析-类的成员函数地址与对象地址动态绑定-this指针-成员函数和成员虚函数反汇编解析
- C++-逆向分析-结构体和类-内存布局-this指针-静态数据成员-对象作为参数和返回值
- Adobe illustrator插件开发-命令名称-AddCommand -AI插件开发
- Adobe illustrator插件开发-事件-PlugPlugAddEventListener-向系统注册事件-AI插件开发
- Adobe illustrator插件开发-ole拖拽粘贴交换数据格式-RegisterClipboardFormat函数-AI插件开发
- Adobe illustrator插件开发-所有模块列表-内部存在大量非公开的Suite-AI插件开发