当前位置:网站首页>Photoshop layer related concepts layercomp layers move rotate duplicate layer compound layer
Photoshop layer related concepts layercomp layers move rotate duplicate layer compound layer
2022-06-27 19:20:00 【Plug in development】
List of articles
1. brief introduction
Photoshop Layers are stacked like transparent paper . Include other elements through layers , You can move layers to move the entire layer .
2. Layer related concepts
2.1.LayerComp
Snapshot of the layer state in the document , It can be used to view different page layouts or compositions . adopt Document.layerComps Collection access . You can access layer composition by name . for example , This is called myLayerComp Of LayerComp Object set comment Property value :
var layercompRef = app.activeDocument.layerComps.getByName("myLayerComp");
layercompRef.comment = "View from shoreline";
2.2.LayerComps
In the document LayerComp A collection of objects . adopt Document.layerComps Collection property access . for example :
app.activeDocument.layerComps.add("myLayerComp", "View from Shoreline",
true, true, true);
2.3.Layers
A collection of layer objects in a document , Include ArtLayer and LayerSet object . By visiting Document.layers or LayerSet.layers Set attribute . for example , This use length Property to calculate the number of layer objects in the active document , Then display the numbers on the screen :
var layerNum = app.activeDocument.layers.length
alert(layerNum)
2.4.LayerSet
A set of layer objects , Can include ArtLayer Objects and others ( Nested )LayerSet object . A single command can manipulate all the layers in the collection . adopt Document.layerSets Set to access the top-level layer set in the document . You can access layer sets by name . for example , The following settings “myLayerSet” Of allLocked value :
var layerSetRef = app.activeDocument.layerSets.getByName("myLayerSet");
layerSetRef.allLocked = true
Through... In the parent set LayerSet.layerSets Set access nested level set . for example :
app.activeDocument.layerSets[0].layerSets[0];
2.5.LayerSets
In the document LayerSet A collection of objects . adopt Document.layerSets Set properties access the top-level layer set in the document . for example :
var layerSetRef = app.activeDocument.layerSets.add()
Through... In the parent set LayerSet.layerSets Set properties access nested sets . for example :
var layerSetRef = app.activeDocument.layerSets.getByName("myParentSet");
var childSet = layerSetRef.layerSets.getByName("myChildSet");
3. Example
3.1. Set the active layer
Set the active layer as the last art layer of the active document .
app.bringToFront();
if (app.documents.length == 0)
{
var docRef = app.documents.add();
}
else
{
var docRef = app.activeDocument;
}
if (docRef.layers.length < 2)
{
docRef.artLayers.add();
}
var activeLayerName = docRef.activeLayer.name;
var setLayerName = "";
if (docRef.activeLayer.name != app.activeDocument.layers[docRef.layers.length - 1].name)
{
docRef.activeLayer = docRef.layers[docRef.layers.length - 1];
}
else
{
docRef.activeLayer = docRef.layers[0];
}
docRef = null;
3.2. Set layer styles
This script demonstrates how to apply styles to layers .
// in case we double clicked the file
app.bringToFront();
$.localize = true;
var strStyleDefaultPuzzleImage = localize( "$$$/Presets/Styles/DefaultStyles_asl/PuzzleImage=Puzzle (Image)" );
var strtRulerUnits = app.preferences.rulerUnits;
if (strtRulerUnits != Units.PIXELS)
{
app.preferences.rulerUnits = Units.PIXELS;
}
if (app.documents.length == 0)
{
var docRef = app.documents.add(320, 240, 72, null, NewDocumentMode.RGB, DocumentFill.WHITE);
}
else
{
var docRef = app.activeDocument;
}
// Make sure activeLayer Not a background layer , So that we can apply styles to it
docRef.activeLayer.isBackgroundLayer = false;
docRef.artLayers[0].applyStyle(strStyleDefaultPuzzleImage);
docRef = null;
if (strtRulerUnits != Units.PIXELS)
{
app.preferences.rulerUnits = strtRulerUnits;
}
3.3. Copy move layer
This script demonstrates how to copy and move layers .
if (!app.documents.length > 0) // Create a new document if the document does not exist
{
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var docRef = app.documents.add(320, 240, 72, null, NewDocumentMode.RGB, DocumentFill.WHITE);
app.preferences.rulerUnits = strtRulerUnits;
}
var docRef = app.activeDocument;
var layerSetRef = docRef.layerSets.add();
var layerRef = docRef.artLayers[0].duplicate();
layerRef.moveToEnd(layerSetRef);
docRef = null;
layerSetRef = null;
layerRef = null;
3.4. Rotate layer
if (app.documents.length > 0)
{
if (app.activeDocument.activeLayer.isBackgroundLayer == false)
{
docRef = app.activeDocument;
layerRef = docRef.layers[0];
layerRef.rotate(45.0);
}
else
{
alert("Operation cannot be performed on background layer");
}
}
else
{
alert("You must have at least one open document to run this script!");
}
3.5. The layer type
if (!app.documents.length > 0) {
// open new file if no document is opened.
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var docRef = app.documents.add(320, 240, 72, null, NewDocumentMode.RGB, DocumentFill.WHITE);
app.preferences.rulerUnits = strtRulerUnits;
}
var docRef = app.activeDocument;
var layerRef = docRef.artLayers.add();
layerRef.kind = LayerKind.TEXT;
docRef = null;
layerRef = null;
4. The author's message
Reasonable script code can effectively improve work efficiency , Reduce repetitive labor .
边栏推荐
猜你喜欢

“我让这个世界更酷”2022华清远见研发产品发布会圆满成功

Hi,你有一份Code Review攻略待查收!

国际数字经济学院、华南理工 | Unified BERT for Few-shot Natural Language Understanding(用于小样本自然语言理解的统一BERT)

International School of Digital Economics, South China Institute of technology 𞓜 unified Bert for few shot natural language understanding

华大单片机KEIL报错_WEAK的解决方案

Good news - British software 2022 has obtained 10 invention patents!

清华徐勇、段文晖研究组开发出高效精确的第一性原理电子结构深度学习方法与程序

Core dynamic Lianke rushes to the scientific innovation board: with an annual revenue of 170million yuan, Beifang Electronics Institute and Zhongcheng venture capital are shareholders

中国工业软件市场研究报告出炉,力控SCADA、MES丰富国产工业软件生态

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
随机推荐
The IPO of Yuchen Airlines was terminated: Guozheng was proposed to raise 500million yuan as the major shareholder
Informatics Orsay all in one 1335: [example 2-4] connected block
ABAP随笔-EXCEL-3-批量导入(突破标准函数的9999行)
华大单片机KEIL报错_WEAK的解决方案
金源高端IPO被终止:曾拟募资7.5亿 儒杉资产与溧阳产投是股东
Market status and development prospect forecast of global 3-Chloro-1,2-Propanediol industry in 2022
Summary of domestic database certification test guide (updated on June 16, 2022)
Vs code runs "yarn run dev" and reports "yarn": the file XXX cannot be loaded
Space calculation of information and innovation industry in 2022
Campus book resource sharing platform
国信证券是国企吗?在国信证券开户资金安全吗?
Comprehensively analyze the zero knowledge proof: resolve the expansion problem and redefine "privacy security"
laravel框架中 定时任务的实现
Teach you how to install Oracle 19C on Windows 10 (detailed picture and text with step on pit Guide)
Market status and development prospect forecast of the global shuttleless air jet loom industry in 2022
基于STM32F103ZET6库函数蜂鸣器实验
Don't worry. This is the truth about wages in all industries in China
Add in address of idea official website
Recommend several open source IOT platforms
im即时通讯开发之双进程守护保活实践