当前位置:网站首页>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 .
边栏推荐
- Redis 原理 - String
- Galaxy Kirin V10 system activation
- 如何封装调用一个库
- Market status and development prospect forecast of global tetramethylammonium hydroxide developer industry in 2022
- Market status and development prospect forecast of the global shuttleless air jet loom industry in 2022
- 一位平凡毕业生的大学四年
- External interrupt experiment based on stm32f103zet6 library function
- MFS分布式文件系统
- Comprehensively analyze the zero knowledge proof: resolve the expansion problem and redefine "privacy security"
- Current market situation and development prospect forecast of global 3,3 ', 4,4' - biphenyltetracarboxylic dianhydride industry in 2022
猜你喜欢

MFS distributed file system

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

数据分析师太火?月入3W?用数据告诉你这个行业的真实情况

OpenSSL client programming: SSL session failure caused by an obscure function

Using WebDAV instead of 445 port file share

Minmei new energy rushes to Shenzhen Stock Exchange: the annual accounts receivable exceeds 600million and the proposed fund-raising is 450million

基于STM32F103ZET6库函数按键输入实验

Redis 原理 - String

Vscode suggests that you enable gopls. What exactly is it?

Keras deep learning practice (12) -- facial feature point detection
随机推荐
Function key input experiment based on stm32f103zet6 Library
[webinar] mongodb and Google cloud accelerate enterprise digital innovation
Galaxy Kirin V10 system activation
推荐几个开源的物联网平台
Campus book resource sharing platform
How to encapsulate and call a library
Exporting coordinates of points in TXT format in ArcGIS
OpenSSL client programming: SSL session failure caused by an obscure function
如何实现IM即时通讯“消息”列表卡顿优化
明美新能源冲刺深交所:年应收账款超6亿 拟募资4.5亿
maxwell 报错(连接为mysql 8.x)解决方法
Bit. Store: long bear market, stable stacking products may become the main theme
Blink SQL built in functions
Gartner聚焦中国低代码发展 UniPro如何践行“差异化”
What is ICMP? What is the relationship between Ping and ICMP?
基于STM32F103ZET6库函数按键输入实验
Code and principle of RANSAC
Cucumber自动化测试框架使用
什么是 ICMP ?ping和ICMP之间有啥关系?
Substrate及波卡一周技术更新速递 20220425 - 20220501