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.pswp.cn/news/274733.shtml 繁體地址,請注明出處:http://hk.pswp.cn/news/274733.shtml 英文地址,請注明出處:http://en.pswp.cn/news/274733.shtml
如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!