将当前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;
  1. /*
  2. How to use:
  3.  
  4. 1) Save this script as LayerToAS3.jsx
  5. 2) Open Photoshop
  6. 3) Select layer in PSD
  7. 4) Go to File > Scripts > Browse > Select this file (LayerToAS3)
  8. 5) Go to AS3 editor and press ctrl+v
  9. You can put this script to hotkey:
  10.  
  11. 1) Go to Window > Actions
  12. 2) Create new folder in the Actions panel
  13. 3) Press Create new action
  14. 4) Put name and choice hotkey
  15. 5) Than press Record
  16. 6) Iterate once "How to use" so action will save script launching parameters
  17. 7) In the Actions panel press Stop button
  18.  
  19. Now you can automatically call this script by button :)
  20.  
  21. */
  22.  
  23. if ( app.documents.length > 0 ) {
  24.  
  25. preferences.rulerUnits = Units.PIXELS;
  26. var layerRef = app.activeDocument.activeLayer;
  27. var layerName = layerRef.name;
  28.  
  29. var x = layerRef.bounds[0].value;
  30. var y = layerRef.bounds[1].value;
  31. var width = layerRef.bounds[2].value - x;
  32. var height = layerRef.bounds[3].value - y;
  33.  
  34. var clp = "";
  35. clp += " " + layerName + ".x = " + x +"; ";
  36. clp += " " + layerName + ".y = " + y +"; ";
  37. clp += " // " + layerName + ".width = " + width +"; ";
  38. clp += " // " + layerName + ".height = " + height +"; ";
  39.  
  40. copyTextToClipboard(clp);
  41. } else {
  42. alert("You must have one opened document at least!");
  43. }
  44.  
  45.  
  46. function copyTextToClipboard(txt){
  47. const keyTextData = app.charIDToTypeID('TxtD');
  48. const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );
  49. var textStrDesc = new ActionDescriptor();
  50. textStrDesc.putString( keyTextData, txt );
  51. executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );
  52. }

以上是关于将当前photoshop层x,y,width,height复制到As3代码的主要内容,如果未能解决你的问题,请参考以下文章

delphi中如何获得当前屏幕photoshop选择区域右上角的坐标值

canvas API

如何按 x,y,width,height 裁剪文件夹中的所有图像,调整它们的大小,然后保存它们?

如何指定 X、Y、宽度和高度以便在 Photoshop 中进行裁剪?

将图层名称复制到 Photoshop 中的文本框的脚本

Photoshop中鼠标位置的x和y坐标