0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AviUtlで文字列から関数を記述してオブジェクトを移動させる

Last updated at Posted at 2020-04-15

目的

AviUtlのアニメーション効果で、ダイアログから自由に関数をstring型で記入し、その関数とトラックバーの変数を用いてオブジェクトの座標を制御する。

方法

loadstring関数を使用します(リファレンス)。
例えば、

function = loadstring("a = 1 + 1")
function()
debug_print(tostring(a))

と記述すると、func()が呼ばれたときにa = 1 + 1が実行され、

2

と表示されます。

サンプル

トラックバーの値を変化させると、ダイアログに記載した関数をもとに座標が変化します。

@自作関数.anm
@自作関数
--track0:X,-1000,1000,0,0.01
--dialog:f(X),fx="x";

x = obj.track0

func = loadstring("y = "..fx)
func()

-- オブジェクトの座標を設定
obj.ox = obj.ox + x
obj.oy = obj.oy + y

-100から100までの直線運動に設定して、AVIに出力してみます。
ダイアログの関数には-xと記述しました。
キャプチャ.PNG
Avi.gif

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?