Created
October 20, 2021 07:32
-
-
Save andywang646691/0e1ea94331771b8298eb8ff0e3f249b5 to your computer and use it in GitHub Desktop.
基于文本基线创建辅助线
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://community.adobe.com/t5/after-effects-discussions/baselinelocs-make-me-confused/td-p/12385553 | |
function addTextLayerBaselineGuide(layer, comp) { | |
guideIndex = []; | |
var anchorPoint = layer.anchorPoint.value, | |
positionPoint = layer.sourcePointToComp([ anchorPoint[0], anchorPoint[1] ]), | |
tlW = layer.sourceRectAtTime(comp.time, !1).width, | |
tlH = layer.sourceRectAtTime(comp.time, !1).height, | |
tlT = layer.sourceRectAtTime(comp.time, !1).top, | |
tlL = layer.sourceRectAtTime(comp.time, !1).left, | |
upLeft = layer.sourcePointToComp([ tlL, tlT ]), | |
bottomRight = layer.sourcePointToComp([ tlW + tlL, tlH + tlT ]); | |
var textLine = layer.text.sourceText.value.baselineLocs.length / 4; | |
var baselineLocs = layer.text.sourceText.value.baselineLocs; | |
tempIndex = comp.addGuide(1, upLeft[0]); | |
guideIndex.push(tempIndex); | |
tempIndex = comp.addGuide(1, bottomRight[0]); | |
guideIndex.push(tempIndex); | |
for (var i = 0; i < textLine; i++) { | |
tempIndex = comp.addGuide(0, positionPoint[1] - anchorPoint[1] + baselineLocs.slice(i * 4, (i + 1) * 4)[1]); | |
guideIndex.push(tempIndex); | |
} | |
} | |
var cc = app.project.activeItem; | |
var sel = cc.selectedLayers[0]; | |
addTextLayerBaselineGuide(sel, cc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment