Photoshop 脚本 - 如何在一种历史记录状态下创建文本图层
Photoshop scripting - how to create text layer in one history state
这个问题 Photoshop 脚本在 Photoshop
中的位图图像中创建文本已经回答了如何在 Photoshop 中创建文本图层,但结果在历史记录选项卡中您可以看到 8-10 个历史记录状态更改。有没有办法做同样的工作,但只改变一次历史?
显然,问题是提到的答案首先将一个图层添加到文档中,然后对其进行 8-10 次编辑,解决方案是创建一个图层并编辑其属性,然后在准备好后将其添加到文档中。
我在 Photoshop CC 2014 Javascript 脚本参考中搜索过,它只列出了 ArtLayers 方法的 3 种方法:add()、getByName() 和 removeAll()。
函数 add() 创建新层,添加它,然后返回它。因此,根据Javascript脚本参考,我不明白如何首先创建一个层然后添加它。
我仍在问,因为可能我错过了一些东西,或者有官方的方法可以做到这一点,但由于某种原因没有进入官方文档。
迟到总比没有好,但是是的,这是可能的。您只需要使用suspendHistory
暂停历史记录状态
只需将您的函数作为字符串以 app.activeDocument.suspendHistory("string", "myFunction()");
据我所知,第一个参数是历史状态字符串。
如示例中,
// Switch off any dialog boxes
displayDialogs = DialogModes.ERROR; // OFF
app.activeDocument.suspendHistory ("history state", "createText('Arial-BoldMT', 48, 0, 128, 0, 'Hello World', 100, 50)");
function createText(fface, size, colR, colG, colB, content, tX, tY)
{
// Add a new layer in the new document
var artLayerRef = app.activeDocument.artLayers.add()
// Specify that the layer is a text layer
artLayerRef.kind = LayerKind.TEXT
//This section defines the color of the hello world text
textColor = new SolidColor();
textColor.rgb.red = colR;
textColor.rgb.green = colG;
textColor.rgb.blue = colB;
//Get a reference to the text item so that we can add the text and format it a bit
textItemRef = artLayerRef.textItem
textItemRef.font = fface;
textItemRef.contents = content;
textItemRef.color = textColor;
textItemRef.size = size
textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top
activeDocument.activeLayer.name = "Text";
activeDocument.activeLayer.textItem.justification = Justification.CENTER;
}
// Set Display Dialogs back to normal
displayDialogs = DialogModes.ALL; // NORMAL
相关文章:
- window.location替换并传递URL历史记录条目中的变量
- Javascript历史记录转换为php行
- 浏览器何时记录历史记录
- 输入类型按钮返回历史记录并返回顶部
- HTML5历史记录-返回上一个完整页面按钮
- Angular JS-如何强制浏览器记录历史以便快速路由
- asp.net网站文件下载历史记录
- 使用Ajax的后退按钮历史记录,URL中没有散列
- 历史记录和通过JavaScript修改的HTML
- Javascript:历史记录未加载页面
- 通过js设置页面历史记录和页面内容
- 如果没有历史记录,我如何隐藏图像或按钮onclick=;历史.go(-1);
- 将HTML表单发布到iframe会导致浏览器历史记录出现问题
- 如何防止浏览器在历史记录中缓存HTML
- 如何将新的stateObject添加或附加到历史记录中
- 检查浏览器后退按钮历史记录
- React-router 在添加历史记录后不会渲染组件
- 如何返回可用的历史记录状态数
- 引导选项卡不适用于历史记录.返回选项
- 非用户发起的操作触发的导航没有记录历史