- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我创建了一个 photoshop Action ,可以将一串白色文本添加到照片中。在此操作中,我编写了一个脚本来扩展 Canvas 大小并调整额外 Canvas 空间内的文本大小以适合图像的尺寸,从而在照片上创建一个“文本选项卡”。但是,在执行 Action 和脚本之后,选项卡中的文本颜色往往……不是白色。
我可以使用什么脚本语法将文本层的颜色更改为白色,以确保它不会随机更改颜色?
作为引用,这里是我编辑文本层的脚本部分:
#target photoshop
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.INCHES;
var doc = app.activeDocument;
var layer = doc.activeLayer;
app.preferences.rulerUnits = Units.PIXELS;
//create the color for the tab extension
var black = new SolidColor();
black.rgb.hexValue = "111111";
app.backgroundColor = black;
//*****************************FOR EXTENDING CANVAS AND POSITIONING/RESIZING THE TEXT LAYER*********************************
var orgWidth = doc.width;
var orgHeight = doc.height;
if(orgWidth>orgHeight) //if document is landscape, resize text to fill a smaller portion of the tab
{
layer.resize(((orgWidth-orgWidth*.2)/(layer.bounds[2]-layer.bounds[0]))*100,(orgWidth*.017/(layer.bounds[3]-layer.bounds[1]))*100,AnchorPosition.TOPLEFT);
doc.resizeCanvas(doc.width, (orgHeight + orgWidth*.04), AnchorPosition.TOPCENTER);
layer.translate(undefined, new UnitValue(0-layer.bounds[1].as('px'),'px'));
layer.translate(undefined, orgHeight);
layer.translate(undefined, (orgWidth*.02-((layer.bounds[3]-layer.bounds[1])/2.3)));
}
else //otherwise, resize text to fill a larger portion of the tab
{
layer.resize(((orgWidth-orgWidth*.05)/(layer.bounds[2]-layer.bounds[0]))*100,(orgWidth*.017/(layer.bounds[3]-layer.bounds[1]))*100,AnchorPosition.TOPLEFT);
doc.resizeCanvas(doc.width, (orgHeight + orgWidth*.04), AnchorPosition.TOPCENTER);
layer.translate(undefined, new UnitValue(0-layer.bounds[1].as('px'),'px'));
layer.translate(undefined, orgHeight);
layer.translate(undefined, (orgWidth*.02-((layer.bounds[3]-layer.bounds[1])/2.3)));
}
var layerWidth = Number(layer.bounds[2] - layer.bounds[0]);
var dX = (orgWidth - layerWidth) / 2 - Number(layer.bounds[0]);
layer.translate(dX, undefined);
doc.flatten(); //flatten the text into the photo
app.preferences.rulerUnits = originalRulerUnits;
最佳答案
对文本添加进行编码可能更容易。这是我为这种场合编写的一个方便的函数。文本居中对齐,但您可以对其进行调整。 (我会包括那部分功能,但它看起来像意大利面条)
var x = (app.activeDocument.width.value)/2;
var y = (app.activeDocument.height.value)/2;
createText("Arial-BoldMT", 10.0, 255,255,255, "Gwen Stefanni is bananas", x, y)
// function CREATE TEXT(typeface, size, R, G, B, text content, text X pos, text Y pos)
// --------------------------------------------------------
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
var just = Justification.CENTER;
activeDocument.activeLayer.textItem.justification = just;
}
关于Javascript Photoshop : Syntax for changing text color of an already existing text layer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30785513/
为大型网站创建所有艺术作品通常涉及几十个 50+mb 的 Photoshop 文件。通常,给定的模块可能出现在多个文件中。 有没有办法从另一个文件引用经常使用的模块? 例如 -“site-sectio
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
我是 Photoshop 脚本的新手。 我想将图像图像(从我的硬盘)作为带有定位的新图层加载到事件文档中。如何才能做到这一点?有人可以分享代码吗? 谢谢 最佳答案 您可以打开 Photoshop 文件
在 photoshop 中,假设我有一些文本图层,其内容如下: Text layer 1: 1@@text01@@abc Text layer 2: 2@@text02@@cef Text lay
我在 Photoshop 中有 500 个图标图像,每个对象周围都有不同的空白区域。我想知道是否有任何方法可以通过 photoshop 运行一个 Action 来裁剪每个图像,以便它删除每个图标周围的
我在 Photoshop 中有 6 个组,每个组中包含多个图层。我希望打开/关闭每个组中的图层以创建图像的所有可能组合。 有人能指出我正确的方向吗? 我从来没有在 Photoshop 中编写过脚本,而
我想开始用 Photoshop 做一些脚本,我想知道是否有一个编辑器已经拥有 Photoshop 的对象或允许加载 Photoshop 的 DOM 以进行智能感知。 任何指针? 最佳答案 Adobe
几乎从一开始,Photoshop 文件就以 8BPS 开始。 (我已经在 2.5 版本中验证了这一点)它在某些时候一定具有某种意义。 我认为 8B 可能指的是位/ channel ,但保存为 16 或
如何在Photoshop中使用Javascript获取/设置当前工具? #target photoshop if (app.currentTool == BRUSH_TOOL) { app.c
几乎从一开始,Photoshop 文件就以 8BPS 开始。 (我已经验证回 2.5 版)它一定在某些时候有一些意义。 我认为 8B 可能指的是位/ channel ,但保存为 16 或 32 没有区
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8 年前关闭。 Improve this
我有非常大的 1 位图像,我需要在 Photoshop 中写入文本数组。我可以在 javascript 中通过将图像转换为灰度然后为每个文本 block 创建一个新层来执行此操作,但我希望能够将文本直
如果我有一个具有以下设置的 photoshop 投影 Blend Mode - rgb(0,0,0) / Opacity - 25% / Angle - 135 degrees / Distance
我正在编写一个脚本,它将遍历图层,修剪它们并导出。到目前为止,我拥有完成此脚本所需的大部分元素。我唯一找不到的是如何显示/隐藏单个图层。我找到了显示/隐藏所有图层的功能,但对于单个图层没有任何功能。
如何在不裁剪的情况下查看矩形选取框选定区域的大小?在paint.net中这很容易,但我必须在photoshop cs 5中完成。在选择区域时,我应该能够看到所选区域的尺寸。我怎样才能做到这一点? 此外
在实现单选按钮时遇到问题。我知道 CS2 中的单选按钮可能有问题,但我不确定哪里出错了。我怀疑我的括号或逗号放错地方了;但看不到它。谢谢。 var dlg = "dialog {text:'Scrip
每种文件格式的技术规范/功能是什么? 一种类型是否比另一种更好地处理某些类型的图形? 最佳答案 XCF 支持保存每一层、当前选择、 channel 、透明度、路径和指南。但是,与 Adobe Ph
我希望 Photoshop 为给定的文件夹自动执行以下任务: 加载给定文件夹中的所有 PNG 文件。 将每个文件的模式转换为RGB 颜色 为每个文件添加一层 在同一文件夹中将文件另存为 PSD 有人告
我第一次编写一些 Photoshop 脚本,如果有一个类似 console.log 的函数来在 ExtendScript Toolkit App 的 Javascript 控制台中输出数组和对象值,那
我不知道如何将我为按钮制作的 Photoshop 形状导入 android,而不带背景。即使我将 photoshop 中的背景设置为透明并将其另存为 PNG,当我在 android 中将它用作我的按钮
我是一名优秀的程序员,十分优秀!