LoginSignup
0
2

More than 5 years have passed since last update.

AE 黄金比などを用いたフォントサイズで決める!

Last updated at Posted at 2018-05-31

作りたかった物その①が完成

bandicam 2018-05-31 19-03-50-261.jpg

フォントサイズを決める時に黄金比など用いてたのですが、それを簡単に設定できるようプログラム作成しました。

使い方は超簡単

ベースとなるフォントサイズを決めたら後は比率を決めるだけで、その比率で計算したフォントサイズを算出してくれて、あとはテキストレイヤーを選択して適応すればOK!!

bandicam 2018-05-31 19-04-18-315.jpg

script またはscript UIフォルダに入れて使ってください!
プログラムのダウンロードはこちらから。
※6月1日午後に若干のアップデートしました。
内容はAeでの最大フォント以上の数値も表示されていましたので、表示されない様にプログラムを改善しました。
https://goo.gl/aRBU11

動画説明も作りました。
https://youtu.be/irg_GcYYeLc

カスタマイズしたい方はこちらのソースを使ってください。

 var ratioObj = [
        ["15:16-minor second",1.067],
        ["8:9 – major second",1.125],
        ["5:6 – minor third",1.2],
        ["4:5 – major third",1.25],
        ["3:4 – perfect fourth",1.333],
        ["1:√2 – aug. fourth / dim. fifth",1.414],
        ["2:3 – perfect fifth",1.5],
        ["5:8 – minor sixth",1.6],
        ["1:1.618 – golden section",1.618],
        ["3:5 – major sixth",1.667],
        ["9:16 – minor seventh",1.778],
        ["8:15 – major seventh",1.875],
        ["1:2 – octave",2],
        ["2:5 – major tenth",2.5],
        ["3:8 – major eleventh",2.667],
        ["1:3 – major twelfth",3],
        ["1:4 – double octave",4]
]
/////Script UI
var winObj = (this instanceof Panel) ? this : new Window("palette", "Font Modular Scall", undefined, {resizeable: true});
//初期登録エリア
var fisrtSetting = winObj.add("panel",/*[20,0,300,120]*/undefined,"Setting");
fisrtSetting.orientation = "column";
//API area
var fontGrp=fisrtSetting.add("group",/*[20,0,300,30]*/);
fontGrp.orientation = "row";
fontGrp.add("statictext",/*[0,10,50,30]*/undefined,"BasesFontSize:");
var inpText = fontGrp.add("edittext",[0,0,50,20],"80");

var ratioGrp=fisrtSetting.add("group",/*[20,0,50,20]*/);
ratioGrp.add("statictext",/*[0,10,50,30]*/undefined,"Ratio:");
var ddl = ratioGrp.add("dropdownlist",undefined);
    for(var i=0; i<ratioObj.length; i++){
    ddl.add("item",ratioObj[i][0]);
    }
ddl.selection=8;

var btnGrp = fisrtSetting.add("group");
//実行ボタン 
//チェックボタン
var loadBtn = btnGrp.add("button",undefined,"load");
var listObj = winObj.add("listbox",[0,0,230,280]);
var applyBtn = winObj.add("button",undefined,"apply");


winObj.onResizing = winObj.onResize = function () {this.layout.resize();};  
if (winObj instanceof Window) {  
            winObj.center();  
            winObj.show();  
        } else {  
            winObj.layout.layout(true);  
            winObj.layout.resize();  
        }  

function roundFloat(number) {
var _pow = Math.pow( 10 , 4 );
return Math.round( number * _pow ) / _pow;
}


loadBtn.onClick = function(){
listObj.removeAll();
var BFS = inpText.text;
var ratioNum = ratioObj[ddl.selection.index][1];//ratioObj配列の計算する方を取得
var dateList = [];
function small(base,target){
dateList.push(BFS)
for( ; ; ){
    if( base < 1 ) break;
    var base = base/target;
     dateList.push(roundFloat(base))
    }
}

function big(base,target){
    for( ; ; ){
    if( base > 2000 ) break;
    var base = base*target;
    dateList.push(roundFloat(base))
    }
}


small(BFS,ratioNum)
dateList.reverse();
big(BFS,ratioNum)

for (i=0; i<dateList.length ;i++){
        if ( dateList[i] > 1296) break;
        listObj.add("item",dateList[i])
}
}

var tl ; //テキストの左側の座標 l
var tw; //テキストの全体の幅 b
var tt ;//テキスト上の座標 c
var th; //テキスト全体の高さ d

function TextLay(fs){
        var curTime = app.project.activeItem.time;
        var myComp = app.project.activeItem;
        var textL =myComp.selectedLayers;
        for (i = 0 ; i< textL.length ; i++){
        var text =  myComp.selectedLayers[i];
        var td = text.property("ADBE Text Properties").property("ADBE Text Document").value; //テキストドキュメント
        td.fontSize=fs;
        text.property("ADBE Text Properties").property("ADBE Text Document").setValue(td)

        var myAnchor = text.property("ADBE Transform Group").property("ADBE Anchor Point");
        tl = text.sourceRectAtTime(curTime, false).left; //テキストの左側の座標 l
        tw =text.sourceRectAtTime(curTime, false).width; //テキストの全体の幅 b
        tt = text.sourceRectAtTime(curTime, false).top;//テキスト上の座標 c
        th = text.sourceRectAtTime(curTime, false).height; //テキスト全体の高さ d
        lv=myAnchor.value;
        var setX=roundFloat((tw/2)+tl);
        var setY=roundFloat((th/2)+tt);
        var setA = myAnchor.setValue([setX,setY]);
}
}


applyBtn.onClick = function(){
        app.beginUndoGroup("font Size");
 TextLay(listObj.selection.text);
    app.endUndoGroup();
}

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2