将当前photoshop层x,y,width,height复制到As3代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将当前photoshop层x,y,width,height复制到As3代码相关的知识,希望对你有一定的参考价值。
This script allow you copy to the clipboard current layer properties in format:&layer_name.x = &layer_x;
&layer_name.y = &layer_y;
// &layer_name.width = &layer_width;
// &layer_name.height = &layer_height;
/* How to use: 1) Save this script as LayerToAS3.jsx 2) Open Photoshop 3) Select layer in PSD 4) Go to File > Scripts > Browse > Select this file (LayerToAS3) 5) Go to AS3 editor and press ctrl+v You can put this script to hotkey: 1) Go to Window > Actions 2) Create new folder in the Actions panel 3) Press Create new action 4) Put name and choice hotkey 5) Than press Record 6) Iterate once "How to use" so action will save script launching parameters 7) In the Actions panel press Stop button Now you can automatically call this script by button :) */ if ( app.documents.length > 0 ) { preferences.rulerUnits = Units.PIXELS; var layerRef = app.activeDocument.activeLayer; var layerName = layerRef.name; var x = layerRef.bounds[0].value; var y = layerRef.bounds[1].value; var width = layerRef.bounds[2].value - x; var height = layerRef.bounds[3].value - y; var clp = ""; clp += " " + layerName + ".x = " + x +"; "; clp += " " + layerName + ".y = " + y +"; "; clp += " // " + layerName + ".width = " + width +"; "; clp += " // " + layerName + ".height = " + height +"; "; copyTextToClipboard(clp); } else { alert("You must have one opened document at least!"); } function copyTextToClipboard(txt){ const keyTextData = app.charIDToTypeID('TxtD'); const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" ); var textStrDesc = new ActionDescriptor(); textStrDesc.putString( keyTextData, txt ); executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO ); }
以上是关于将当前photoshop层x,y,width,height复制到As3代码的主要内容,如果未能解决你的问题,请参考以下文章
delphi中如何获得当前屏幕photoshop选择区域右上角的坐标值
如何按 x,y,width,height 裁剪文件夹中的所有图像,调整它们的大小,然后保存它们?