Photoshop activeDocument.gradients 属性

发布于 2024-12-14 09:53:07 字数 110 浏览 0 评论 0原文

我正在使用 Photoshop cs4,当我使用 adobe 脚本检查此属性时,我得到未定义的结果。如何访问 Photoshop 中文档加载的渐变并通过脚本对其进行操作(例如修改渐变停止点、删除渐变……)?

I'm using Photoshop cs4 and when I use adobe script to check this property, I get undefined. How can I access to the loaded gradients of the documents in Photoshop to manipulate them by script (for example modifying a gradient stop, delete the gradient,...)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺ぐ爱和你が 2024-12-21 09:53:07

我知道这是一篇旧帖子,Photoshop 参考指南中似乎没有任何有关渐变属性的信息。但是...

使用 scriptlistner 在空白的 640x640 图像上有一个简单的前景对于背景渐变,我们得到:

// =======================================================
var id148 = charIDToTypeID( "Grdn" );
var desc24 = new ActionDescriptor();
var id149 = charIDToTypeID( "From" );
var desc25 = new ActionDescriptor();
var id150 = charIDToTypeID( "Hrzn" );
var id151 = charIDToTypeID( "#Pxl" );
desc25.putUnitDouble( id150, id151, 639.000000 ); //x1
var id152 = charIDToTypeID( "Vrtc" );
var id153 = charIDToTypeID( "#Pxl" );
desc25.putUnitDouble( id152, id153, 0.000000 ); //y1
var id154 = charIDToTypeID( "Pnt " );
desc24.putObject( id149, id154, desc25 );
var id155 = charIDToTypeID( "T   " );
var desc26 = new ActionDescriptor();
var id156 = charIDToTypeID( "Hrzn" );
var id157 = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( id156, id157, 639.000000 ); //x2
var id158 = charIDToTypeID( "Vrtc" );
var id159 = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( id158, id159, 639.000000 ); //y2
var id160 = charIDToTypeID( "Pnt " );
desc24.putObject( id155, id160, desc26 );
var id161 = charIDToTypeID( "Type" );
var id162 = charIDToTypeID( "GrdT" );
var id163 = charIDToTypeID( "Lnr " );
desc24.putEnumerated( id161, id162, id163 );
var id164 = charIDToTypeID( "UsMs" );
desc24.putBoolean( id164, true );
var id165 = charIDToTypeID( "Grad" );
var desc27 = new ActionDescriptor();
var id166 = charIDToTypeID( "Nm  " );
desc27.putString( id166, "Foreground to Background" ); // name of the gradient
var id167 = charIDToTypeID( "GrdF" );
var id168 = charIDToTypeID( "GrdF" );
var id169 = charIDToTypeID( "CstS" );
desc27.putEnumerated( id167, id168, id169 );
var id170 = charIDToTypeID( "Intr" );
desc27.putDouble( id170, 4096.000000 );
var id171 = charIDToTypeID( "Clrs" );
var list5 = new ActionList();
var desc28 = new ActionDescriptor();
var id172 = charIDToTypeID( "Type" );
var id173 = charIDToTypeID( "Clry" );
var id174 = charIDToTypeID( "FrgC" );
desc28.putEnumerated( id172, id173, id174 );
var id175 = charIDToTypeID( "Lctn" );
desc28.putInteger( id175, 0 );
var id176 = charIDToTypeID( "Mdpn" );
desc28.putInteger( id176, 50 );
var id177 = charIDToTypeID( "Clrt" );
list5.putObject( id177, desc28 );
var desc29 = new ActionDescriptor();
var id178 = charIDToTypeID( "Type" );
var id179 = charIDToTypeID( "Clry" );
var id180 = charIDToTypeID( "BckC" );
desc29.putEnumerated( id178, id179, id180 );
var id181 = charIDToTypeID( "Lctn" );
desc29.putInteger( id181, 4096 );
var id182 = charIDToTypeID( "Mdpn" );
desc29.putInteger( id182, 50 );
var id183 = charIDToTypeID( "Clrt" );
list5.putObject( id183, desc29 );
desc27.putList( id171, list5 );
var id184 = charIDToTypeID( "Trns" );
var list6 = new ActionList();
var desc30 = new ActionDescriptor();
var id185 = charIDToTypeID( "Opct" );
var id186 = charIDToTypeID( "#Prc" );
desc30.putUnitDouble( id185, id186, 100.000000 );
var id187 = charIDToTypeID( "Lctn" );
desc30.putInteger( id187, 0 );
var id188 = charIDToTypeID( "Mdpn" );
desc30.putInteger( id188, 50 );
var id189 = charIDToTypeID( "TrnS" );
list6.putObject( id189, desc30 );
var desc31 = new ActionDescriptor();
var id190 = charIDToTypeID( "Opct" );
var id191 = charIDToTypeID( "#Prc" );
desc31.putUnitDouble( id190, id191, 100.000000 );
var id192 = charIDToTypeID( "Lctn" );
desc31.putInteger( id192, 4096 );
var id193 = charIDToTypeID( "Mdpn" );
desc31.putInteger( id193, 50 );
var id194 = charIDToTypeID( "TrnS" );
list6.putObject( id194, desc31 );
desc27.putList( id184, list6 );
var id195 = charIDToTypeID( "Grdn" );
desc24.putObject( id165, id195, desc27 );
executeAction( id148, desc24, DialogModes.NO );

不幸的是,这并不像仅通过名称调用所需的渐变那么简单,您最好使用脚本列表程序使用所需的渐变进行录制。

这篇帖子< /a> 可能对你也有用

I'm aware this is an old post and there doesn't appear to be any information on the gradient properties in Photoshop refrence guide.However...

Using scriptlistner with a on a blank 640x640 image a simple foreground to background gradient we get this:

// =======================================================
var id148 = charIDToTypeID( "Grdn" );
var desc24 = new ActionDescriptor();
var id149 = charIDToTypeID( "From" );
var desc25 = new ActionDescriptor();
var id150 = charIDToTypeID( "Hrzn" );
var id151 = charIDToTypeID( "#Pxl" );
desc25.putUnitDouble( id150, id151, 639.000000 ); //x1
var id152 = charIDToTypeID( "Vrtc" );
var id153 = charIDToTypeID( "#Pxl" );
desc25.putUnitDouble( id152, id153, 0.000000 ); //y1
var id154 = charIDToTypeID( "Pnt " );
desc24.putObject( id149, id154, desc25 );
var id155 = charIDToTypeID( "T   " );
var desc26 = new ActionDescriptor();
var id156 = charIDToTypeID( "Hrzn" );
var id157 = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( id156, id157, 639.000000 ); //x2
var id158 = charIDToTypeID( "Vrtc" );
var id159 = charIDToTypeID( "#Pxl" );
desc26.putUnitDouble( id158, id159, 639.000000 ); //y2
var id160 = charIDToTypeID( "Pnt " );
desc24.putObject( id155, id160, desc26 );
var id161 = charIDToTypeID( "Type" );
var id162 = charIDToTypeID( "GrdT" );
var id163 = charIDToTypeID( "Lnr " );
desc24.putEnumerated( id161, id162, id163 );
var id164 = charIDToTypeID( "UsMs" );
desc24.putBoolean( id164, true );
var id165 = charIDToTypeID( "Grad" );
var desc27 = new ActionDescriptor();
var id166 = charIDToTypeID( "Nm  " );
desc27.putString( id166, "Foreground to Background" ); // name of the gradient
var id167 = charIDToTypeID( "GrdF" );
var id168 = charIDToTypeID( "GrdF" );
var id169 = charIDToTypeID( "CstS" );
desc27.putEnumerated( id167, id168, id169 );
var id170 = charIDToTypeID( "Intr" );
desc27.putDouble( id170, 4096.000000 );
var id171 = charIDToTypeID( "Clrs" );
var list5 = new ActionList();
var desc28 = new ActionDescriptor();
var id172 = charIDToTypeID( "Type" );
var id173 = charIDToTypeID( "Clry" );
var id174 = charIDToTypeID( "FrgC" );
desc28.putEnumerated( id172, id173, id174 );
var id175 = charIDToTypeID( "Lctn" );
desc28.putInteger( id175, 0 );
var id176 = charIDToTypeID( "Mdpn" );
desc28.putInteger( id176, 50 );
var id177 = charIDToTypeID( "Clrt" );
list5.putObject( id177, desc28 );
var desc29 = new ActionDescriptor();
var id178 = charIDToTypeID( "Type" );
var id179 = charIDToTypeID( "Clry" );
var id180 = charIDToTypeID( "BckC" );
desc29.putEnumerated( id178, id179, id180 );
var id181 = charIDToTypeID( "Lctn" );
desc29.putInteger( id181, 4096 );
var id182 = charIDToTypeID( "Mdpn" );
desc29.putInteger( id182, 50 );
var id183 = charIDToTypeID( "Clrt" );
list5.putObject( id183, desc29 );
desc27.putList( id171, list5 );
var id184 = charIDToTypeID( "Trns" );
var list6 = new ActionList();
var desc30 = new ActionDescriptor();
var id185 = charIDToTypeID( "Opct" );
var id186 = charIDToTypeID( "#Prc" );
desc30.putUnitDouble( id185, id186, 100.000000 );
var id187 = charIDToTypeID( "Lctn" );
desc30.putInteger( id187, 0 );
var id188 = charIDToTypeID( "Mdpn" );
desc30.putInteger( id188, 50 );
var id189 = charIDToTypeID( "TrnS" );
list6.putObject( id189, desc30 );
var desc31 = new ActionDescriptor();
var id190 = charIDToTypeID( "Opct" );
var id191 = charIDToTypeID( "#Prc" );
desc31.putUnitDouble( id190, id191, 100.000000 );
var id192 = charIDToTypeID( "Lctn" );
desc31.putInteger( id192, 4096 );
var id193 = charIDToTypeID( "Mdpn" );
desc31.putInteger( id193, 50 );
var id194 = charIDToTypeID( "TrnS" );
list6.putObject( id194, desc31 );
desc27.putList( id184, list6 );
var id195 = charIDToTypeID( "Grdn" );
desc24.putObject( id165, id195, desc27 );
executeAction( id148, desc24, DialogModes.NO );

Unfortunately, it's not as easy as just calling the gradient you need by name, you might be better off recording using the desired gradient with the scriptlistner.

This post might be useful to you as well

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文