word文本样式代码样式
As of After Effects 17.0, you can use expressions to edit text styles in After Effects. Here’s why this would transform your workflow:
从After Effects 17.0开始,您可以使用表达式在After Effects中编辑文本样式。 这就是这将改变您的工作流程的原因:
- Title Design: Link multiple text layers to one source of truth, for consistency and precision. 标题设计:将多个文本层链接到一个事实来源,以保持一致性和准确性。
- Save time: Don’t waste your precious mental energy and hours of the day clicking into individual text layers, Character and Paragraph panels, or even expression sliders controlling your text. 节省时间:不要浪费您宝贵的精力和一天中的几个小时单击单个文本图层,“字符”和“段落”面板,甚至控制文本的表达滑块。
- Create Motion Graphics Templates (mogrts): Link your source(s) of typographic truth to the Essential Graphics panel, so that you or others can edit them with flexibility in After Effects and Premiere. 创建运动图形模板(迁移):将印刷真相源链接到“基本图形”面板,以便您或其他人可以在After Effects和Premiere中灵活地对其进行编辑。
Example:
例:
You have three text layers. You want to maintain the same styling and source text for all, but you want to control Paragraph Alignment in the Essential Graphics panel.
您有三个文本层。 您希望为所有对象保留相同的样式和源文本,但是要在“基本图形”面板中控制“段落对齐”。
For the skeptics: Yes, you can manually change the paragraph alignment, but you’re likely pushing the same copy to multiple comps at various sizes. The After Effects gods gave us new features so that maybe we can work more precisely and intelligently. Keep things simple for simpler projects, and go a little complex for more complex projects.
对于怀疑者:是的,您可以手动更改段落的对齐方式,但是您可能会将同一副本推入各种大小的多个伴奏中。 After Effects神灵为我们提供了新功能,以便我们可以更精确,更智能地工作。 对于较简单的项目,请保持简单;对于较复杂的项目,则应使它变得有些复杂。
Recipe:
食谱:
- Use expressions to link the three text layers to one master text layer (your source of truth). 使用表达式将三个文本层链接到一个主文本层(您的真相来源)。
- Create a Dropdown Menu Control with Paragraph Alignment options. 使用段落对齐选项创建一个下拉菜单控件。
Add this expression to each of the three text layers:
将此表达式添加到三个文本层中的每个:
var t = thisComp.layer("MASTER TITLE").text.sourceText; var fontSize = t.style.fontSize; var leading = t.style.leading; style = t.style; styleA = style.setFontSize(fontSize); styleB = styleA.setText(t); styleC = styleB.setLeading(leading);
var t = thisComp.layer("MASTER TITLE").text.sourceText; var fontSize = t.style.fontSize; var leading = t.style.leading; style = t.style; styleA = style.setFontSize(fontSize); styleB = styleA.setText(t); styleC = styleB.setLeading(leading);
Explanation, line by line:
逐行说明:
var t = thisComp.layer("MASTER TITLE").text.sourceText;
var t = thisComp.layer("MASTER TITLE").text.sourceText;
Declare a variable, t, and return the value of your master text layer’s sourceText.
声明一个变量t,并返回主文本层的sourceText的值。
var fontSize = t.style.fontSize;
var fontSize = t.style.fontSize;
Declare a variable, fontSize
, and return the fontSize of t
.
声明一个变量fontSize
,并返回t
的fontSize。
var leading = t.style.leading;
var leading = t.style.leading;
Declare a variable, leading
, and return the leading of t
.
声明一个变量, leading
,并返回t
的领先。
style = t.style;
style = t.style;
Adding style
to the end is the same as using getStyleAt(0);
which means to get the style of t
at Character Index 0. You can also use getStyleAt(n, x);
to return the Character Index at Time (n = character index, x = time in seconds).
最后添加style
与使用getStyleAt(0);
您也可以使用getStyleAt(n, x);
来获取字符索引0处的t
样式getStyleAt(n, x);
返回时间的字符索引(n =字符索引,x =以秒为单位的时间)。
The variables styleA, styleB, and styleC combine Set Functions using the variables we declared above: fontSize, sourceText, and leading. I’ve separated each style for clarity, but you can also write everything in longform.
变量styleA,styleB和styleC使用我们上面声明的变量fontSet,sourceText和Lead组合了Set函数。 为了清楚起见,我将每种样式分开,但您也可以用长格式编写所有内容。
Now that we’ve linked the text layers to a single style, let’s create a Dropdown Menu Control so that we can access Left, Center, or Right paragraph alignment in the Essential Graphics Panel.
现在,我们已经将文本图层链接到一个样式,现在我们创建一个下拉菜单控件,以便我们可以在Essential Graphics Panel中访问Left,Center或Right段落对齐方式。
Use this expression on the opacity of your text layers (but make sure their visibility is still turned on):
在文本图层的不透明度上使用此表达式(但请确保它们的可见性仍处于打开状态):
var x = thisComp.layer("CONTROL").effect("paragraphAlign")("Menu").value; if (x == 1) 100; else 0
var x = thisComp.layer("CONTROL").effect("paragraphAlign")("Menu").value; if (x == 1) 100; else 0
Explanation, line by line:
逐行说明:
var x = thisComp.layer("CONTROL").effect("paragraphAlign")("Menu").value;
var x = thisComp.layer("CONTROL").effect("paragraphAlign")("Menu").value;
Declare a variable x, and return the value of a Dropdown Menu Item. The value of a Dropdown Menu item is always a number, even if you rename the label.
声明一个变量x,并返回一个下拉菜单项的值。 即使重命名标签,“下拉菜单”项的值也始终是数字。
if (x == 1) 100; else 0
if (x == 1) 100; else 0
If x is equal 1, the opacity will be 100. Otherwise, it will be zero.
如果x等于1,则不透明度将为100。否则,它将为零。
Note that you may encounter the triple equals operator, or the strict equality operator, ===
, e.g., x === 1
. This operator is special because it tests for both value (e.g., 5) and type (e.g., number).
请注意,您可能会遇到三重等于运算符或严格等于运算符===
,例如x === 1
。 该运算符很特殊,因为它同时测试值(例如5)和类型(例如数字)。
In this example, x === 1
will still work. However, if you type x === "1"
, then the test will return false because the Dropdown Menu item values are always numbers, not strings.
在此示例中, x === 1
仍然有效。 但是,如果键入x === "1"
,则测试将返回false,因为下拉菜单项的值始终是数字,而不是字符串。
Done! Now read more about text styling expressions over at Adobe.
做完了! 现在,在Adobe上阅读有关文本样式表达的更多信息。
Originally published at https://bytanchan.com on March 21, 2020.
最初于 2020年3月21日 在 https://bytanchan.com 上 发布 。
翻译自: https://uxdesign.cc/creating-your-source-of-truth-with-text-styling-expressions-ee38bebe7c35
word文本样式代码样式
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274733.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!