diff --git a/docs/anim.html b/docs/anim.html
new file mode 100644
index 0000000..0071c41
--- /dev/null
+++ b/docs/anim.html
@@ -0,0 +1,160 @@
+
+
+
+
+
+anim ライブラリ
+
+
+anim は、アニメーションでよく使う計算をまとめた補助ライブラリです。
+補間・イージング・波・範囲変換・ベクトル・ノイズ・色変換と、便利な定数を提供します。
+これらは標準 Lua にはない、このエフェクト独自の関数です。
+
+
+定数
+
+
+定数 値 説明
+anim.taumath.pi * 2円一周分のラジアン。周期運動に使う
+anim.eネイピア数 自然対数の底
+anim.phi(1 + sqrt(5)) / 2黄金比
+anim.sqrt2sqrt(2)2 の平方根
+
+
+obj.x = obj.x + math.sin(time * anim.tau) * 100
+
+補間・イージング
+
+
+イージング関数はおおむね 0.0 ~ 1.0 の進行度 t を受け取り、変化のカーブを返します。
+obj.t をそのまま渡すのが定番です。
+
+
+
+関数 説明
+anim.lerp(a, b, t)a と b を t で線形補間
+anim.smoothstep(e0, e1, x)e0 ~ e1 をエルミート補間で滑らかに遷移
+anim.smootherstep(e0, e1, x)2 次導関数まで連続な、より滑らかな遷移
+anim.ease_in(t)2 次イーズイン(加速)
+anim.ease_out(t)2 次イーズアウト(減速)
+anim.ease_in_out(t)2 次イーズイン・アウト(加速後減速)
+anim.elastic(t)弾むようなスプリングイージング(t は 0 ~ 1 にクランプ)
+anim.back(t)行き過ぎてから戻るイージング
+anim.bounce(t)バウンドするイージング(t は 0 ~ 1 にクランプ)
+anim.step(edge, x)x が edge 以上なら 1.0、未満なら 0.0
+anim.bezier(t, p0, p1, p2, p3)t における 3 次ベジェ曲線の値(t は 0 ~ 1 にクランプ)
+
+
+2 点間をイージングで移動
+local tx, ty = 200, -100
+local p = anim.ease_in_out(obj.t)
+obj.x = anim.lerp(obj.x, tx, p)
+obj.y = anim.lerp(obj.y, ty, p)
+
+弾むように登場
+local p = anim.duration(time, 0.3)
+obj.zoom = obj.zoom * anim.elastic(p)
+
+範囲・周期
+
+
+関数 説明
+anim.clamp(v, lo, hi)v を lo ~ hi に収める
+anim.map(v, a1, b1, a2, b2)範囲 a1~b1 の v を a2~b2 に変換
+anim.norm(v, lo, hi)v が lo~hi のどの割合(0.0~1.0)かを返す
+anim.wrap(v, lo, hi)v を lo ~ hi でループさせる
+anim.pingpong(t, len)0 ~ len を往復する値
+anim.sign(v)符号(正=1, 負=-1, ゼロ=0)
+anim.fract(v)小数部分のみ
+anim.oscillate(t, lo, hi, freq)周波数 freq で lo~hi を正弦波で往復
+anim.triangle(t, freq)周波数 freq で 0.0~1.0 を往復する三角波
+anim.square(t, freq)周波数 freq で 1.0 と 0.0 を切り替える矩形波
+anim.duration(t, dur)時間 dur に対する割合(0.0~1.0、クランプあり)
+anim.delay(t, d)時間 d を引いた値(0 未満は 0)
+
+
+値の範囲変換
+obj.rz = anim.map(obj.track0, 0, 100, -180, 180)
+
+滑らかな明滅
+obj.alpha = anim.oscillate(time, 64, 255, 1)
+
+ベクトル・幾何
+
+
+関数 戻り値 説明
+anim.len(x, y)数値 ベクトル (x, y) の長さ
+anim.dist(x1, y1, x2, y2)数値 2 点間の距離
+anim.dot(x1, y1, x2, y2)数値 2 ベクトルの内積
+anim.normalize(x, y)x, y 正規化した方向ベクトル(2 値で返す)
+anim.polar(r, a)x, y 半径 r・角度 a(度)から移動量
+anim.rotate(x, y, a)x, y (x, y) を a(度)回転させた座標
+
+
+円運動
+local r = obj.track0
+local dx, dy = anim.polar(r, time * 90)
+obj.x = obj.x + dx
+obj.y = obj.y + dy
+
+ノイズ・乱数
+
+
+関数 説明
+anim.noise(x [, y [, z]])1 ~ 3 次元の滑らかなノイズ(0.0 ~ 1.0)。同じ座標では常に同じ値
+anim.rand(s)シード s に基づく 0.0 ~ 1.0 の安定した乱数
+anim.rand(max, s)0.0 ~ max の安定した乱数
+anim.rand(min, max, s)min ~ max の安定した乱数
+
+
+
+
anim.rand はシードのみで決まる小数の乱数です(フレームは関与しません)。
+整数で、フレームによっても変えたい場合は
obj.rand を使ってください。
+
+
+安定した乱数で個体差をつける
+local offset = anim.rand(-50, 50, obj.layer)
+obj.x = obj.x + offset
+
+ノイズで揺らぐ手ぶれ風
+obj.x = obj.x + (anim.noise(time * 2, 0, 0) - 0.5) * 20
+obj.y = obj.y + (anim.noise(0, time * 2, 0) - 0.5) * 20
+obj.rz = (anim.noise(0, 0, time * 2) - 0.5) * 10
+
+色変換
+
+
+関数 戻り値 説明
+anim.hsv_to_rgb(h, s, v)r, g, b HSV(色相 0~360, 彩度 0~1, 明度 0~1)を RGB(0~255)へ変換
+anim.rgb_to_hsv(r, g, b)h, s, v RGB(0~255)を HSV へ変換
+
+
+時間で色相を回す
+local hue = anim.wrap(time * 60, 0, 360)
+local cr, cg, cb = anim.hsv_to_rgb(hue, 1, 1)
+local pd = obj.getpixeldata()
+local n = pd.width * pd.height
+for i = 0, n - 1 do
+ local base = i * 4
+ pd:set(base + 1, pd:get(base + 1) * cr / 255)
+ pd:set(base + 2, pd:get(base + 2) * cg / 255)
+ pd:set(base + 3, pd:get(base + 3) * cb / 255)
+end
+
+
+
+
+
+
+
diff --git a/docs/assets/nav.js b/docs/assets/nav.js
new file mode 100644
index 0000000..90a6067
--- /dev/null
+++ b/docs/assets/nav.js
@@ -0,0 +1,101 @@
+(function () {
+ var NAV = [
+ {
+ group: "はじめに",
+ items: [
+ { title: "概要", href: "index.html" },
+ { title: "導入と使い方", href: "getting-started.html" }
+ ]
+ },
+ {
+ group: "Lua 言語",
+ items: [
+ { title: "Lua の基礎", href: "lua-basics.html" },
+ { title: "標準ライブラリ", href: "stdlib.html" }
+ ]
+ },
+ {
+ group: "API リファレンス",
+ items: [
+ { title: "グローバル変数", href: "globals.html" },
+ { title: "obj オブジェクト", href: "obj.html" },
+ { title: "obj の関数", href: "obj-functions.html" },
+ { title: "anim ライブラリ", href: "anim.html" },
+ { title: "scene と ymm4", href: "scene-ymm4.html" },
+ { title: "ピクセル操作", href: "pixels.html" }
+ ]
+ },
+ {
+ group: "高度な機能",
+ items: [
+ { title: "エンジンと高速化", href: "engines.html" },
+ { title: "パラメータ指定子", href: "directives.html" }
+ ]
+ },
+ {
+ group: "実用",
+ items: [
+ { title: "サンプル集", href: "samples.html" },
+ { title: "クイックリファレンス", href: "reference.html" },
+ { title: "制限事項とトラブル", href: "limits.html" }
+ ]
+ }
+ ];
+
+ function currentFile() {
+ var path = window.location.pathname;
+ var file = path.substring(path.lastIndexOf("/") + 1);
+ return file === "" ? "index.html" : file;
+ }
+
+ function build() {
+ var here = currentFile();
+ var sidebar = document.getElementById("sidebar");
+ if (!sidebar) return;
+
+ var html = '
-
-
-Luaスクリプト for YMM4 サンプル集
+Lua スクリプト for YMM4
-YukkuriMovieMaker4 の「Luaスクリプト」映像エフェクトで使えるサンプルと、
-利用可能な変数・関数・定数の一覧をまとめたページです。
-各サンプルはエフェクトのスクリプト欄にそのまま貼り付けて利用できます。
-スクリプトエンジンは MoonSharp (Lua 5.2 互換) です。
+YukkuriMovieMaker4 の映像エフェクト「Lua スクリプト」の公式ドキュメントです。
+このエフェクトでは、Lua のコードで映像を毎フレーム加工できます。座標・回転・拡大率・不透明度の制御から、
+ピクセル単位の画像処理、図形やテキストの生成、ほかのエフェクトの呼び出しまでを、1 つのスクリプト欄で行えます。
-変数・関数の詳細な仕様は、スクリプトエディタのヘルプ、または
-docs/LuaScript.ja-jp.txt を参照してください。
+標準のスクリプトエンジンは Lua 5.2 互換の MoonSharp です。
+重いピクセル処理のためには、LuaJIT で実行する --!native レーンと、
+CPU・GPU カーネルへ変換する --!cpu・--!gpu レーンも用意しています。
+詳しくはエンジンと高速化 を参照してください。
-
+
+このドキュメントは、プラグインの実装そのものに基づいて記述しています。
+変数・関数・定数の名前と挙動は、スクリプトエディタの入力補完に表示されるものと一致します。
+
+
+このドキュメントの構成
-目次
-
-
-
+最小の例
-サンプルの読み方
-
-スクリプト内では、変更可能な obj の値(座標・拡大率・回転・不透明度など)を
-書き換えると描画に反映されます。読み戻されるのは
-x, y, z, ox, oy, zoom, aspect, alpha, rx, ry, rz
-(およびラジアン版 rxr, ryr, rzr、独立スケール sx, sy)です。
-
-
-time はアイテム基準の経過秒数、obj.t はアイテム内の進行割合
-(0.0 ~ 1.0) です。グローバル変数の状態はフレーム間で保持されません。
-math.random は毎フレーム同じシードで初期化されるため、同一フレームでは
-同じ値を返します。安定した乱数が必要な場合は anim.rand を使います。
-
+エフェクトを追加した直後に入っている既定のスクリプトは、フェードインです。
-
-
-1. 基本
-
-1-1. フェードイン (デフォルトスクリプト)
obj.alpha = math.min(time * 255, 255)
-1-2. フェードアウト
-obj.alpha = math.max((obj.totalframe - obj.frame) / obj.framerate * 255, 0)
-
-1-3. Track0 で不透明度を制御
-obj.alpha = obj.track0
-
-1-4. 時間に応じて回転
-obj.rz = time * 90
-
-1-5. Track0 でズームを制御
-obj.zoom = obj.zoom * (1 + obj.track0 / 100)
-
-
-
-2. 座標と動き
-
-2-1. 左右の揺れ
-Track0 を振幅(px)、Track1 を周波数(回/秒)として使います。
-local amp = obj.track0
-local freq = obj.track1
-obj.x = obj.x + math.sin(time * anim.tau * freq) * amp
-
-2-2. 円運動
-local r = obj.track0
-local dx, dy = anim.polar(r, time * 90)
-obj.x = obj.x + dx
-obj.y = obj.y + dy
-
-2-3. バウンド (跳ねる)
-local h = obj.track0
-obj.y = obj.y - anim.bounce(anim.pingpong(time, 1)) * h
-
-2-4. ゆらぎ (ノイズによる手ぶれ風)
-obj.x = obj.x + (anim.noise(time * 2, 0, 0) - 0.5) * 20
-obj.y = obj.y + (anim.noise(0, time * 2, 0) - 0.5) * 20
-obj.rz = (anim.noise(0, 0, time * 2) - 0.5) * 10
-
-2-5. 中心オフセットを基準に振り子運動
-回転中心 ox, oy をずらして振り子のように揺らします。
-obj.oy = -obj.hh
-obj.rz = math.sin(time * anim.tau) * 30
-
-
-
-3. 回転
-
-3-1. 度とラジアン
-rx, ry, rz は度、rxr, ryr, rzr はラジアンです。
-ラジアン版を変更するとそちらが優先して反映されます。
-
-obj.rzr = time * anim.tau
-
-3-2. Y軸回転で立体的に回す
-obj.ry = time * 180
-
-3-3. 加速しながら回転 (イージング)
-obj.rz = anim.ease_in(obj.t) * 360
-
-
-
-4. 拡大・変形
-
-4-1. 弾むように登場 (スケールイン)
-local p = anim.duration(time, 0.3)
-obj.zoom = obj.zoom * anim.elastic(p)
-
-4-2. アスペクト比で横伸び・縦伸び
-
-aspect は正で横方向に縮小、負で縦方向に縮小します。
-
-obj.aspect = math.sin(time * anim.tau) * 0.5
-
-4-3. X・Y を独立して拡大 (sx, sy)
-ぷにぷにと潰れる動きを sx, sy で表現します。
-local s = math.sin(time * anim.tau * 2) * 0.2
-obj.sx = 1 + s
-obj.sy = 1 - s
-
-
-
-5. 不透明度・フェード
-
-5-1. 遅延フェードイン
-local p = anim.duration(anim.delay(time, 0.5), 1)
-obj.alpha = p * 255
-
-5-2. 点滅 (矩形波)
-obj.alpha = anim.square(time, 4) * 255
-
-5-3. 滑らかな明滅 (正弦波)
-obj.alpha = anim.oscillate(time, 64, 255, 1)
-
-
-
-6. anim 補間・イージング
-
-6-1. 2点間をイージングで移動
-local tx, ty = 200, -100
-local p = anim.ease_in_out(obj.t)
-obj.x = anim.lerp(obj.x, tx, p)
-obj.y = anim.lerp(obj.y, ty, p)
-
-6-2. 行き過ぎてから戻る (back)
-obj.x = obj.x + anim.back(obj.t) * 200
-
-6-3. しきい値で切り替え (step / smoothstep)
-obj.alpha = anim.smoothstep(0, 0.5, obj.t) * 255
-
-補間・イージング系関数の一覧です。
-
-関数 説明
-anim.lerp(a, b, t) a と b を t (0.0~1.0) で線形補間
-anim.smoothstep(e0, e1, x) e0~e1 をエルミート補間で滑らかに遷移
-anim.smootherstep(e0, e1, x) 2次導関数まで連続な、より滑らかな遷移
-anim.ease_in(t) 2次イーズイン (加速)
-anim.ease_out(t) 2次イーズアウト (減速)
-anim.ease_in_out(t) 2次イーズイン・アウト (加速後減速)
-anim.elastic(t) 弾むようなスプリングイージング
-anim.back(t) 行き過ぎてから戻るイージング
-anim.bounce(t) バウンドするイージング
-anim.step(edge, x) x が edge 以上なら 1.0、未満なら 0.0
-anim.bezier(t, p0, p1, p2, p3) t における3次ベジェ曲線の値
-
-
-
-
-7. anim 範囲・周期
-
-7-1. 値の範囲変換 (map)
-obj.rz = anim.map(obj.track0, 0, 100, -180, 180)
-
-7-2. 三角波で往復
-obj.x = obj.x + (anim.triangle(time, 1) - 0.5) * 200
-
-範囲・周期系関数の一覧です。
-
-関数 説明
-anim.clamp(v, lo, hi) v を lo ~ hi の範囲に収める
-anim.map(v, a1, b1, a2, b2) 範囲 a1~b1 の v を a2~b2 に変換
-anim.norm(v, lo, hi) v が lo~hi のどの割合 (0.0~1.0) かを取得
-anim.wrap(v, lo, hi) v を lo ~ hi でループさせる
-anim.pingpong(t, len) 0 ~ len を往復する値
-anim.sign(v) 符号 (正=1, 負=-1, ゼロ=0)
-anim.fract(v) 小数部分のみを取得
-anim.oscillate(t, lo, hi, freq) freq の周波数で lo~hi を正弦波で往復
-anim.triangle(t, freq) freq の周波数で 0.0~1.0 を往復する三角波
-anim.square(t, freq) freq の周波数で 1.0 と 0.0 を切り替える矩形波
-anim.duration(t, dur) 時間 dur に対する割合 (0.0~1.0, clamp あり)
-anim.delay(t, d) 時間 d 経過後から開始する時間 (0以下は0)
-
-
-
-
-8. anim ベクトル・幾何
-
-8-1. 座標を回転させる
-local rx, ry = anim.rotate(obj.track0, 0, time * 90)
-obj.x = obj.x + rx
-obj.y = obj.y + ry
-
-8-2. 2点間の距離で挙動を変える
-local d = anim.dist(obj.x, obj.y, 0, 0)
-obj.alpha = anim.clamp(255 - d, 0, 255)
-
-ベクトル・幾何系関数の一覧です。
-
-関数 説明
-anim.len(x, y) ベクトル (x, y) の長さ
-anim.dist(x1, y1, x2, y2) 2点間の距離
-anim.dot(x1, y1, x2, y2) 2ベクトルの内積
-anim.normalize(x, y) 正規化した方向ベクトル (Tuple で返却)
-anim.polar(r, a) 半径 r・角度 a(度) から移動量 (x, y)
-anim.rotate(x, y, a) (x, y) を a(度) 回転させた座標
-
-
-
-
-9. anim ノイズ・乱数
-
-9-1. 安定した乱数で個体差をつける
-
-anim.rand はシード引数に基づく決定的な乱数です。レイヤー番号をシードにすると
-オブジェクトごとに異なる固定値が得られます。
-
-local offset = anim.rand(-50, 50, obj.layer)
-obj.x = obj.x + offset
-
-9-2. ノイズで揺らぐ不透明度
-obj.alpha = anim.noise(time, obj.layer, 0) * 255
-
-
-関数 説明
-anim.noise(x, y, z) 1~3次元の滑らかなノイズ (0.0~1.0)
-anim.rand(min, max, s) シード s に基づく安定した乱数
-
-
-
-
-10. anim 色
-
-10-1. 時間で色相を回す (虹色)
-local hue = anim.wrap(time * 60, 0, 360)
-local cr, cg, cb = anim.hsv_to_rgb(hue, 1, 1)
-local pd = obj.getpixeldata()
-local n = pd.width * pd.height
-for i = 0, n - 1 do
- local base = i * 4
- pd:set(base + 1, pd:get(base + 1) * cr / 255)
- pd:set(base + 2, pd:get(base + 2) * cg / 255)
- pd:set(base + 3, pd:get(base + 3) * cb / 255)
-end
-
-
-関数 説明
-anim.hsv_to_rgb(h, s, v) HSV (色相0~360, 彩度0~1, 明度0~1) を RGB に変換
-anim.rgb_to_hsv(r, g, b) RGB (0~255) を HSV に変換
-
-
-
-
-11. anim 定数
-
-定数 説明
-anim.tau 円周率の2倍 (math.pi * 2)
-anim.e ネイピア数 (math.exp(1))
-anim.phi 黄金比 ((1 + math.sqrt(5)) / 2)
-anim.sqrt2 2の平方根 (math.sqrt(2))
-
-
-
-
-12. 他オブジェクトの参照 (obj.getobject)
-
-
-obj.getobject(tag [, frame]) は、対象アイテムの「備考」欄に入力した文字列を
-タグとして、そのアイテムの描画情報を取得します。備考欄はプロパティエリアの上側にあります。
-第2引数 frame を指定すると、そのタイムラインフレーム時点の値を取得します
-(省略時は現在フレーム)。返り値は対象アイテム自身の座標・回転・拡大率であり、
-グループ制御・カメラ制御による変形は含みません。一致するアイテムが無い場合は
-nil を返します。同じタグのアイテムが複数あるときは、対象フレームで
-表示中のものを優先します。
+obj.alpha に値を代入すると不透明度が変わります。time はアイテム先頭からの経過秒数です。
+スクリプトはフレームごとに実行され、obj の値を書き換えると描画へ反映されます。
-12-1. 発射元の座標に合わせる
-local src = obj.getobject("routersys")
-if src then
- obj.x = src.x
- obj.y = src.y
-end
+できることの全体像
-12-2. 発射元へ向かって移動する
-local target = obj.getobject("routersys")
-if target then
- local p = anim.ease_in_out(obj.t)
- obj.x = anim.lerp(obj.x, target.x, p)
- obj.y = anim.lerp(obj.y, target.y, p)
-end
-
-12-3. 発射元へ向きながら移動する (ファンネル風)
-local target = obj.getobject("routersys")
-if target then
- local p = anim.ease_in_out(obj.t)
- local nx = anim.lerp(obj.x, target.x, p)
- local ny = anim.lerp(obj.y, target.y, p)
- obj.rz = math.deg(math.atan2(target.y - obj.y, target.x - obj.x))
- obj.x = nx
- obj.y = ny
-end
-
-12-4. 一定速度で接近し、到達したら停止
-local target = obj.getobject("routersys")
-if target then
- local dx = target.x - obj.x
- local dy = target.y - obj.y
- local dist = anim.len(dx, dy)
- if dist > 0 then
- local step = math.min(dist, obj.track0 * obj.time)
- obj.x = obj.x + dx / dist * step
- obj.y = obj.y + dy / dist * step
- end
-end
-
-12-5. 表示中のときだけ追従する
-local target = obj.getobject("routersys")
-if target and target.exist then
- obj.x = target.x
- obj.y = target.y
-end
-
-12-6. 発射元の拡大率・回転・不透明度も引き継ぐ
-local src = obj.getobject("routersys")
-if src then
- obj.x = src.x
- obj.y = src.y
- obj.zoom = src.zoom
- obj.rz = src.rz
- obj.alpha = src.alpha
-end
-
-12-7. 発射時の座標に固定する
-
-弾の発射フレーム (弾アイテムの開始フレーム) は timelineframe - frame で
-求まります。そのフレーム時点の発射元座標を取得すれば、発射元が動いても弾の原点は
-発射位置に固定されます。
-
-local fire = timelineframe - frame
-local src = obj.getobject("routersys", fire)
-if src then
- obj.x = src.x
- obj.y = src.y
-end
-
-返り値テーブルのメンバーは以下のとおりです。
-
-メンバー 説明
-exist 対象フレームが表示期間内か (boolean)
-x / y / z 描画位置 (ピクセル)
-zoom / sx / sy 拡大率 (1.0 で等倍)
-rx / ry / rz X / Y / Z 軸回転角 (度)
-rxr / ryr / rzr X / Y / Z 軸回転角 (ラジアン)
-alpha 不透明度 (0.0 ~ 255.0)
-layer レイヤー番号
+
+分野 主な API 参照
+座標・回転・拡大率・不透明度の制御 obj.x, obj.rz, obj.zoom, obj.alpha ほかobj
+時間・フレーム情報 time, frame, obj.t, timelineframeグローバル変数
+アニメーション補間・波・ノイズ・色 anim.lerp, anim.ease_in_out, anim.noise, anim.hsv_to_rgbanim
+他アイテムの参照 obj.getobjectobj の関数
+ピクセル操作 obj.getpixel, obj.setpixel, obj.getpixeldataピクセル操作
+図形・テキスト・画像・動画の読み込み obj.load, obj.setfontobj の関数
+他エフェクトの適用・描画 obj.effect, obj.draw, obj.drawpolyobj の関数
+シーン・環境情報 scene.width, ymm4.is_savingscene / ymm4
+パラメータ UI の定義 --track@, --check@, --color@, --dialog:パラメータ指定子
+高速化エンジンの選択 --!native, --!cpu, --!gpuエンジンと高速化
-
-
-13. ピクセル操作
-
-
-ピクセル操作は実際の入力画像へアクセスするため、初回アクセス時に画像データの
-転送が発生します。座標は画像の左上を (0, 0) とし、右・下方向が正です。
-取得値はストレートアルファ相当です。
-
-
-13-1. getpixel / setpixel で赤成分を反転
-for y = 0, obj.h - 1 do
- for x = 0, obj.w - 1 do
- local r, g, b, a = obj.getpixel(x, y)
- obj.setpixel(x, y, 255 - r, g, b, a)
- end
-end
-
-13-2. getpixeldata でグレースケール (高速)
-
-obj.getpixeldata() はピクセルへ直接アクセスできるプロキシを返します。
-インデックスは 1 始まりで、チャンネルは R, G, B, A の繰り返しです。
-pixel(x, y) の R チャンネルのインデックスは (y * obj.w + x) * 4 + 1 です。
-
-local pd = obj.getpixeldata()
-local w = pd.width
-local h = pd.height
-for y = 0, h - 1 do
- for x = 0, w - 1 do
- local base = (y * w + x) * 4
- local r = pd:get(base + 1)
- local g = pd:get(base + 2)
- local b = pd:get(base + 3)
- local gray = r * 0.299 + g * 0.587 + b * 0.114
- pd:set(base + 1, gray)
- pd:set(base + 2, gray)
- pd:set(base + 3, gray)
- end
-end
-
-13-3. 中心からの距離でフェード (円形ビネット)
-local pd = obj.getpixeldata()
-local w = pd.width
-local h = pd.height
-local cx = w / 2
-local cy = h / 2
-local maxd = anim.len(cx, cy)
-for y = 0, h - 1 do
- for x = 0, w - 1 do
- local base = (y * w + x) * 4
- local d = anim.len(x - cx, y - cy)
- local k = anim.clamp(1 - d / maxd, 0, 1)
- pd:set(base + 4, pd:get(base + 4) * k)
- end
-end
-
-
-obj.putpixeldata() は AviUtl との互換性のために存在しますが、
-このプラグインでは変更が自動的に反映されるため呼び出す必要はありません (no-op)。
-
-
-
-関数 戻り値 説明
-obj.getpixel(x, y) r, g, b, a 指定座標のピクセルを取得 (各成分 0~255)
-obj.setpixel(x, y, r, g, b [, a]) なし 指定座標へ書き込み (a 既定 255)
-obj.getpixeldata() PixelDataProxy 全ピクセルへの直接アクセスプロキシ
-obj.putpixeldata() なし 互換用の空実装
-
-
-
-
-14. シーン情報 (scene)
-
-14-1. シーンサイズに対する相対配置
-obj.x = scene.cx * obj.track0 / 100
-
-
-メンバー 説明
-scene.width シーンの横解像度 (ピクセル)
-scene.height シーンの縦解像度 (ピクセル)
-scene.cx 横解像度の半分 (= scene.width / 2)
-scene.cy 縦解像度の半分 (= scene.height / 2)
-
-
-
-
-15. 環境・メタ情報 (ymm4)
-
-15-1. グループ内のインデックスで時間差をつける
-local d = ymm4.group_index * 0.1
-local p = anim.duration(anim.delay(time, d), 0.5)
-obj.alpha = p * 255
-
-15-2. グループ内の進行割合で配置をずらす
-obj.x = obj.x + ymm4.group_ratio * 400
-
-15-3. 出力時のみ挙動を変える
-if ymm4.is_saving then
- obj.alpha = 255
-else
- obj.alpha = 128
-end
-
-
-メンバー 説明
-ymm4.group_index グループ制御内の現在のインデックス (0始まり)
-ymm4.group_count グループ制御内の総アイテム数
-ymm4.group_ratio グループ内の進行割合 (group_index / group_count)
-ymm4.timeline_totalframe タイムライン全体の総フレーム数
-ymm4.timeline_totaltime タイムライン全体の総時間 (秒)
-ymm4.time_ratio 現在の再生位置の割合 (0.0 ~ 1.0)
-ymm4.is_saving 動画出力中のみ true
-ymm4.is_playing 再生中のみ true
-ymm4.is_paused 一時停止中のみ true
-ymm4.scene_id 現在のシーンを識別する文字列 (Guid)
-
-
-
-
-16. グローバル変数
-以下の変数はスクリプトのグローバルスコープで直接参照できます (すべて読み取り専用)。
-
-変数 説明
-time オブジェクト基準の現在時間 (秒)。obj.time と同じ
-frame オブジェクト基準の現在フレーム番号。obj.frame と同じ
-totalframe オブジェクトの総フレーム数。obj.totalframe と同じ
-framerate フレームレート (fps)。obj.framerate と同じ
-timelineframe タイムライン先頭からの絶対フレーム番号
-timelinetime タイムライン基準の現在時間 (秒)
-layer 配置されているレイヤー番号。obj.layer と同じ
-obj / scene / ymm4 / anim 各テーブル (本ページ参照)
-
-
-
-
-17. 標準ライブラリ
-利用できる標準ライブラリは以下に限定されます。io, os, debug, ffi, require 等は使用できません。
-
-math
-
-abs, ceil, cos, exp, floor, fmod, huge, log, max, min, modf, pi, random, randomseed,
-sin, sqrt, tan, atan, atan2, deg, rad, ldexp, frexp, sinh, cosh, tanh, type,
-tointeger, maxinteger, mininteger
-
-
-string
-
-format, len, sub, upper, lower, rep, reverse, find, match, gmatch, gsub, byte, char,
-dump, pack, unpack, packsize
-
-
-table
-insert, remove, sort, concat, unpack, move
-
-bit32
-
-band, bor, bxor, bnot, lshift, rshift, arshift, extract, replace, btest, countlz, countrz
-
-
-基本関数
-
-type, tostring, tonumber, select, error, assert, print, ipairs, pairs, next, unpack,
-setmetatable, getmetatable, rawget, rawset, rawequal, rawlen, pcall, xpcall
-
-
-
-
-クイックリファレンス
-
-obj (変更可能メンバー)
-
-メンバー 説明
-obj.x / obj.y / obj.z 描画位置 (ピクセル)
-obj.ox / obj.oy / obj.oz 回転中心のオフセット (ピクセル)
-obj.zoom 拡大率 (sx と sy の平均、1.0 で等倍)
-obj.aspect アスペクト比 (-1.0 ~ 1.0)
-obj.sx / obj.sy X / Y 方向の独立拡大率
-obj.alpha 不透明度 (0.0 ~ 255.0)
-obj.rx / obj.ry / obj.rz X / Y / Z 軸回転角 (度)
-obj.rxr / obj.ryr / obj.rzr X / Y / Z 軸回転角 (ラジアン)
-
-
-obj (読み取り専用メンバー)
-
-メンバー 説明
-obj.w / obj.h 入力画像の幅 / 高さ (ピクセル)
-obj.hw / obj.hh 幅 / 高さの半分
-obj.cx / obj.cy 画像中心 (= hw / hh)
-obj.cz / obj.sz 常に 0 / 常に 1
-obj.diagonal 対角線長 (sqrt(w^2 + h^2))
-obj.time / obj.frame アイテム基準の経過時間 (秒) / フレーム
-obj.totalframe / obj.totaltime アイテムの総フレーム数 / 総時間 (秒)
-obj.t アイテム内の進行割合 (0.0 ~ 1.0)
-obj.framerate フレームレート (fps)
-obj.layer レイヤー番号
-obj.index / obj.num グループ内のインデックス / 総数
-obj.track0 ~ obj.track3 エフェクトパネルの各トラックバーの値
-
-
-obj 関数
-
-関数 説明
-obj.getobject(tag [, frame]) 他アイテムの描画情報を取得 (本ページ 12 章)
-obj.getpixel(x, y) ピクセル取得
-obj.setpixel(x, y, r, g, b [, a]) ピクセル書き込み
-obj.getpixeldata() ピクセル直接アクセスプロキシ
-obj.putpixeldata() 互換用の空実装
-
-
-
-
-非対応・制限事項
-
-AviUtl2 の obj.effect(), obj.draw(), obj.drawpoly(), obj.load() 等は非対応です。
-obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor() 等は非対応です。
-scene.set(), scene.get() 等は非対応です (scene.width / scene.height の読み取りのみ)。
-ファイルアクセス (require, dofile, io 等) は非対応です。
-スクリプトのタイムアウトは 5 秒です。無限ループに注意してください。
---track@, --check@ 等のヘッダーディレクティブは非対応です (Track0 ~ Track3 のみ)。
-
-
-
-
-
-Luaスクリプト for YMM4 / MIT License /
-https://github.com/routersys/YMM4-LuaScript
-
+
+
+