目標のOpenWeatherMap APIで作るアニメーション
プログラムを始める時に「OpenWeatherMapのAPIを活用してお天気ニュース的なものを作る」という事を目標にしていたのですが、もう少しで完成しそうです!!
あとはUIを考えてって感じで、進み具合は60%ぐらいでしょうか。。。
その作業の中でjsonからテキストデータを大量に引っ張ってそれぞれ設定してたら大変なのでコンストラクタによるファンクションで設定しようと思っています。
コンストラクタ内でアンカーポイントの設定を行ってます。
OpenWeatherMapからのjsonから大量に配列であるのであとはfor文で一気にテキスト出力しようと思っています。
とりあえずメモまで
addText("〇〇〇〇")ココにテキストを入れたら
テキストレイヤーが作成され、アンカーポイントも真ん中に設定されます。
//アンカーを真ん中に
function addText(Layertext,fs){
app.beginUndoGroup("moving anchor");
function roundFloat(number) {
var _pow = Math.pow( 10 , 4 );
return Math.round( number * _pow ) / _pow;
}
var myComp = app.project.activeItem;
var curTime = app.project.activeItem.time;
cNText = myComp.layers.addText(Layertext);
var cNTextTd = cNText.property("ADBE Text Properties").property("ADBE Text Document").value; //テキストドキュメント
cNTextTd.fontSize = fs;
cNText.property("ADBE Text Properties").property("ADBE Text Document").setValue(cNTextTd);
var myAnchor = cNText.property("ADBE Transform Group").property("ADBE Anchor Point");
var tl = cNText.sourceRectAtTime(curTime, false).left; //テキストの左側の座標 l
var tw =cNText.sourceRectAtTime(curTime, false).width; //テキストの全体の幅 b
var tt = cNText.sourceRectAtTime(curTime, false).top;//テキスト上の座標 c
var th = cNText.sourceRectAtTime(curTime, false).height; //テキスト全体の高さ d
var lv=myAnchor.value;
var setX=roundFloat((tw/2)+tl);
var setY=roundFloat((th/2)+tt);
var setA = myAnchor.setValue([setX,setY]);
app.endUndoGroup();
}
addText("ここにテキストを入力する",100)