如何使用ExtendScript更改After Effects 2017中文本图层的颜色?
问题描述:
我需要知道如何使用ExtendScript更改After Effects 2017中文本图层的颜色。我可以很简单地更改文本本身,如下所示:如何使用ExtendScript更改After Effects 2017中文本图层的颜色?
var comp=app.project.item(10);
comp.layer(1).property('Source Text').setValue('My Text Here');
但是,如何设置该文本图层的颜色?我会认为这会很简单,但是尽管有很多搜索,我还没有找到任何明确解释如何做到这一点的内容。
在此先感谢!
答
After Effects CS6 Scripting guide的第182页(Adobe公司给出的最新文档)描述了TextDocument对象,它是文本图层的Source Text属性的数据类型。其中属性是fillColor和strokeColor。
编辑它并不像看起来那么简单,你不能只分配值的源文本,你必须做出一个新的textDocument对象,使您的更改,然后分配的值源文本属性添加到您创建的textDocument对象。
因此可以这样设置:
var textProp = comp.layer(1).property('Source Text');
//make a new textDocument, copying the values of the current one
var textDocument = textProp.value;
// change any attributes of the textDocument here, e.g.:
textDocument.fillColor = [R, G, B];
// write the textDocument over the existing one
textProp.setValue(textDocument);
R,G和B是浮点值,其中1.0⇒255中的8位的颜色。
你也可以看到,脚本指南在网上aeenhancers有它描述了构造一个错字,它说newTextDocument
它应该是new TextDocument
我试过了。它不会改变图层的颜色。例如,我用这个... var comp = app.project.item(17); comp.layer(1).property('Source Text')。fillColor = c; 其中c是[255,255,255] ...但文字不会变成白色。 –
尝试'[1,1,1]'该值是一个介于0和1之间的8位项目的浮点数,其中1映射到255 – stib
dangit,忘记添加'.value'来获取源文本的值。我已经修改了我的答案。 – stib