コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
484a26ec45
|
||
|
|
a121a598b6
|
||
|
|
6dd70413a9
|
||
|
|
ac482b6041
|
||
|
|
c2761c0796
|
||
|
|
3bbd411d86
|
||
|
|
324faabb96
|
||
|
|
32b706cb8b
|
||
|
|
aa97c52b38
|
||
|
|
a2f0231739
|
||
|
|
2905192d3a
|
||
|
|
ee6f6bd9c1
|
||
|
|
8853f5e403
|
||
|
|
867de7aa73
|
||
|
|
e384d7e490
|
||
|
|
87e060d71d
|
||
|
|
9c6167d224
|
||
|
|
a8a91103e1
|
||
|
|
4a2f4b2dbb
|
||
|
|
33fc45639b
|
||
|
|
7af803e46e
|
||
|
|
48e8287704
|
||
|
|
7eff4591f0
|
||
|
|
5b1bb4ad6e
|
||
|
|
7f3e6b0019
|
||
|
|
7519a11851
|
||
|
|
4193c40f41
|
||
|
|
cd68bf86b0
|
||
|
|
9948204265
|
||
|
|
25670bde90
|
||
|
|
ae230c0e10
|
||
|
|
7ee8f1ccf0
|
||
|
|
da88898a67
|
||
|
|
3c63ba0729
|
||
|
|
e7382ac289
|
||
|
|
ee7e4f43bc
|
||
|
|
7dc6e9fb40
|
||
|
|
803534d804
|
||
|
|
a25803fa30
|
||
|
|
e42401670f
|
||
|
|
a139326c39
|
||
|
|
496c237f50
|
||
|
|
dfbcbded98
|
||
|
|
2ebbe3ced0
|
||
|
|
9671cba5a1
|
||
|
|
947532f064
|
||
|
|
6e3594eb01
|
||
|
|
abc7b2cde2
|
||
|
|
68d862ded0
|
||
|
|
d3060fd202
|
||
|
|
1d92d80a86
|
||
|
|
86ad19105f
|
||
|
|
2cd5ab273a
|
||
|
|
d75aeee3c2
|
||
|
|
981fb2ceeb
|
||
|
|
01a0dcb9ae
|
||
|
|
460b5e6252
|
||
|
|
fb02580836
|
||
|
|
58a5f59b19
|
||
|
|
95598b1a88
|
||
|
|
7f436ebe17
|
||
|
|
d620f7ea3b
|
||
|
|
ad377a0923
|
||
|
|
f374038000
|
||
|
|
ddba8d63c2
|
||
|
|
ab2e195139
|
||
|
|
85c585db89
|
||
|
|
93eb681b0e
|
||
|
|
30ca75f65e
|
||
|
|
a07916de6b
|
||
|
|
467a4b0dd8
|
||
|
|
03aad4cc6e
|
||
|
|
b638c7b9c2
|
||
|
|
ede56971cd
|
||
|
|
94c11dffcb
|
||
|
|
28c1f70fa1
|
||
|
|
2ecde28980
|
||
|
|
1c2c3915e9
|
||
|
|
9f2cab9961
|
||
|
|
e1778c7c73
|
||
|
|
98426f4ca8
|
||
|
|
7358e2b0a1
|
||
|
|
1af7b8fc8b
|
||
|
|
26d7b0c470
|
||
|
|
96400605ba
|
||
|
|
695cb2f04d
|
||
|
|
6b39a4cceb
|
||
|
|
4b4252855b
|
||
|
|
0d6c3285e1
|
||
|
|
3bcf206a95
|
||
|
|
c65bb5b08f
|
||
|
|
e5b9b98a27
|
||
|
|
7906d4c735
|
||
|
|
d879f3c6fa
|
||
|
|
e7ae3bf290
|
||
|
|
735fd86bed
|
||
|
|
813b3d6686
|
||
|
|
ca43e3706b
|
||
|
|
ef4d7e8024
|
||
|
|
299da15bb8
|
||
|
|
ffba68aeb0
|
||
|
|
1085294aa0
|
||
|
|
cb7e4622e8
|
||
|
|
06e2afa7ed
|
||
|
|
3e60c6d77f
|
||
|
|
594517b436
|
||
|
|
1d3b924492
|
検索条件に一致するファイルはありません
+92
-26
@@ -1,46 +1,112 @@
|
||||
# v1.9.1 - Lua スクリプト for YMM4
|
||||
# v1.11.0 - Lua スクリプト for YMM4
|
||||
|
||||
チェック(check0〜check3)とカラー(color)を、AviUtl 互換の `--check`/`--color`
|
||||
ヘッダ宣言だけでなく、スクリプト本体で参照するだけでエフェクトパネルへ自動表示できる
|
||||
ようにしたマイナーリリースです。トラックバー(track0〜track3)と同じ感覚で、必要な
|
||||
入力欄だけを `--` ヘッダ無しで出せます。既存のヘッダ宣言・トラック常時表示の挙動は
|
||||
変わりません。
|
||||
AviUtl 互換の描画 API を拡張したリリースです。`obj.draw` / `obj.drawpoly` の合成モード、
|
||||
作業画像の出力可否を切り替える `draw_state`、描画先を `tmp` バッファへ切り替える
|
||||
`drawtarget`、アンカー座標を Lua 変数として扱う `obj.setanchor` を追加しました。
|
||||
MoonSharp とネイティブの両エンジンで同じ API を使えるようにし、内蔵ドキュメントも
|
||||
各言語で更新しました。
|
||||
|
||||
---
|
||||
|
||||
## 新機能・機能改善
|
||||
|
||||
### 1. check / color の参照による UI 自動表示
|
||||
### 1. obj.setoption("blend", 合成モード)
|
||||
|
||||
スクリプト本体で `obj.check0`〜`obj.check3` や `color` を参照すると、対応する
|
||||
チェックボックス・カラーピッカーがエフェクトパネルへ自動的に表示されます(参照を
|
||||
消すと非表示に戻ります)。AviUtl 互換時と同じ動的表示機構をそのまま用いており、
|
||||
`--` ヘッダを書かずに必要な入力欄だけを出せます。
|
||||
`obj.draw` / `obj.drawpoly` の合成モードを `obj.setoption("blend", 番号)` で指定できるように
|
||||
しました。
|
||||
|
||||
- トラックバー(track0〜track3)は従来どおり常に表示されます。
|
||||
- この一般利用では `--` 引数による範囲・既定値の宣言を伴わないため、値の範囲は
|
||||
スクリプト内で扱います(クランプは行いません)。
|
||||
- 参照表示したカラーピッカーの値は `color` としてスクリプトへ供給されます。
|
||||
- AviUtl 互換の `--track` / `--check` / `--color` ヘッダによる宣言表示は従来どおり
|
||||
利用できます。
|
||||
- 番号は YMM4 のプロパティパネルにある「合成モード」の並びと同じで、0 から始まります。
|
||||
- 0 は通常、1 はディザ合成、2 は比較(暗)、3 は乗算、4 は焼き込みカラー、5 は
|
||||
焼き込み(リニア)、6 は比較(明)、7 はスクリーン、8 は覆い焼きカラー、9 は
|
||||
覆い焼き(リニア) - 加算、10 は加算、11 はオーバーレイ、12 はソフトライト、13 は
|
||||
ハードライト、14 はビビッドライト、15 はリニアライト、16 はピンライト、17 は
|
||||
ハードミックス、18 は差分、19 は除外、20 は減算、21 は除算、22 は色相、23 は彩度、
|
||||
24 はカラー、25 は輝度、26 はカラー比較(明)、27 は背景、28 はカラー比較(暗)、
|
||||
29 は削除、30 は背景でクリッピング、31 は重ならない部分のみ、32 は色反転マスクです。
|
||||
- 範囲外の値や数値ではない値は通常として扱います。
|
||||
- MoonSharp とネイティブの両エンジンで、`obj.draw` と `obj.drawpoly` の描画コマンドへ
|
||||
合成モードを渡します。
|
||||
|
||||
### 2. 入力補完への登録
|
||||
### 2. obj.setoption("draw_state", true / false)
|
||||
|
||||
スクリプトエディタの入力補完候補に `obj.check0`〜`obj.check3` と `color` を追加し、
|
||||
トラック(`obj.track0`〜`obj.track3`)と同様に補完できるようにしました。
|
||||
このエフェクトが作業画像を出力するかどうかを、スクリプトから明示できるようにしました。
|
||||
|
||||
- `true` を指定すると、`setpixel` や `obj.draw` を使わない場合でも作業画像を出力します。
|
||||
- `false` を指定すると、このエフェクトの作業画像出力を抑制します。
|
||||
- 未指定の場合は従来どおり、ピクセル変更や描画コマンドの有無に従います。
|
||||
- MoonSharp とネイティブの両エンジンで動作します。
|
||||
|
||||
### 3. obj.setoption("drawtarget", "framebuffer" / "tempbuffer")
|
||||
|
||||
`obj.draw` / `obj.drawpoly` の描画先を切り替えられるようにしました。
|
||||
|
||||
- `"framebuffer"` は既定の描画先です。描画コマンドはフレームバッファへ合成されます。
|
||||
- `"tempbuffer"` を指定すると、描画コマンドは作業用の `tmp` バッファへその場で合成されます。
|
||||
- `obj.setoption("drawtarget", "tempbuffer", w, h)` のように幅と高さを渡すと、そのサイズで
|
||||
`tmp` バッファを用意します。
|
||||
- `tmp` へ描いた結果は `obj.copybuffer("obj", "tmp")` で作業画像へ戻せます。
|
||||
- `tempbuffer` への合成は通常のソースオーバーで行い、`blend` はフレームバッファへの描画に
|
||||
適用します。
|
||||
- 描画先は毎フレーム既定の `"framebuffer"` へ戻ります。
|
||||
- MoonSharp とネイティブの両エンジンで動作します。
|
||||
|
||||
### 4. obj.setanchor(name, count [, option, ...])
|
||||
|
||||
アンカー座標を Lua 変数へ格納する `obj.setanchor` を追加しました。
|
||||
|
||||
- `name` で指定した名前の Lua 変数へ、`{x0, y0, x1, y1, ...}` の配列を作成します。
|
||||
- `"xyz"` を指定した場合は `{x0, y0, z0, x1, y1, z1, ...}` の 3D 座標になります。
|
||||
- `count` は 0〜32 に制限され、戻り値は実際に設置した個数です。
|
||||
- 保存済みの座標がある場合はその値を使い、無い場合は 8 列の既定グリッド座標を使います。
|
||||
- `"line"` / `"loop"` / `"star"` / `"arm"` の線結び指定と、`"xyz"` の 3D 指定を受け付けます。
|
||||
- `name` に `"track"` を指定するトラックバー連携は未対応で、0 を返します。
|
||||
- MoonSharp とネイティブの両エンジンで同じ座標テーブルを受け取れるようにしました。
|
||||
|
||||
### 5. 内蔵ドキュメントの更新
|
||||
|
||||
同梱される `LuaScript/docs/LuaScript.*.txt` を更新し、`blend`、`draw_state`、
|
||||
`drawtarget`、`obj.setanchor` の説明を各言語へ追加しました。
|
||||
|
||||
---
|
||||
|
||||
## 互換性・後方互換
|
||||
|
||||
- ヘッダ宣言時の表示やトラックバーの常時表示など、既存の挙動は変わりません。
|
||||
- 参照検出は、ヘッダ(`--`)を用いない一般利用時にのみ加算的に働きます。
|
||||
- `blend` の既定値は 0 の通常です。指定しない既存スクリプトの合成結果は変わりません。
|
||||
- `drawtarget` の既定値は `"framebuffer"` です。フレームをまたいで前回の描画先は持ち越しません。
|
||||
- `draw_state` を指定しない場合は、従来どおりピクセル変更や描画コマンドに応じて出力します。
|
||||
- `obj.setanchor` を含むスクリプトは、自動判定では描画 API を使うスクリプトとして扱います。
|
||||
ネイティブで実行する場合は、従来どおり明示ディレクティブを使えます。
|
||||
- `tempbuffer` への描画は通常合成です。`blend` による合成モード指定は、フレームバッファへの
|
||||
`obj.draw` / `obj.drawpoly` に適用されます。
|
||||
- `obj.setanchor("track", ...)` によるトラックバー連携は未対応で、0 を返します。
|
||||
|
||||
---
|
||||
|
||||
## 内部実装
|
||||
|
||||
- 参照検出は既存の Lua 字句解析器(`LuaLexer`)を再利用し、文字列・コメントを除外
|
||||
した正確な検出を行います(カスタム UI の新設なし)。
|
||||
- 全 8 言語(日本語・英語・簡体字中国語・繁体字中国語・韓国語・スペイン語・
|
||||
インドネシア語・アラビア語)のドキュメントへ、本挙動を追記しました。
|
||||
- YMM4 の `Blend` 列挙値へ番号を対応させる `BlendModeMap` を追加し、`DrawCommand` へ
|
||||
合成モード番号を持たせました。
|
||||
- `DrawCompositor` は通常以外の合成モードで `DrawImage` / `BlendImage` を使い、Opacity の
|
||||
出力をキャッシュして毎描画ごとの COM オブジェクト確保を避けるようにしました。
|
||||
- `SoftwareCompositor` を追加し、MoonSharp 側で最近傍または線形補間による
|
||||
`obj.draw` / `obj.drawpoly` の `tempbuffer` 合成を行えるようにしました。
|
||||
- ネイティブワーカー側にも同等のソフトウェア合成処理を追加しました。
|
||||
- `AviUtlScriptContext` に `DrawStateOverride`、描画先状態、アンカー入力元、アンカー要求一覧を
|
||||
追加しました。描画先が `tempbuffer` の場合は `DrawCommand` を通常の描画キューへ積まず、
|
||||
その場で `tmp` バッファへ合成します。
|
||||
- `LuaAnchorPoint` と `AnchorSupport` を追加し、アンカー数の制限、オプション解析、既定座標、
|
||||
保存済み座標の解決、ドラッグ後の座標更新を分離しました。
|
||||
- アンカー要求から生成した `VideoEffectController` を `DrawDescription.Controllers` へ追加し、
|
||||
YMM4 のプレビュー操作へ渡すようにしました。
|
||||
- アンカー座標の変更をキャッシュキーへ含めるため、エフェクト側へ `AnchorVersion` を追加しました。
|
||||
- ネイティブプロトコルへ `draw_state` の書き戻しフィールドと `setanchor` コールバック種別を
|
||||
追加しました。`LuaJitWorker` は `draw` / `drawpoly` の合成モード、`draw_state`、
|
||||
`setanchor` の座標解決をワーカーとやり取りします。
|
||||
- ネイティブワーカーでは `drawtarget` 用の `tmp` バッファ、`obj.setanchor`、
|
||||
`draw_state` の書き戻しを実装しました。
|
||||
- ネイティブワーカーの `obj.copybuffer` は、`tmp` や名前付きキャッシュへ書き込むときに
|
||||
バッファを複製するようにしました。
|
||||
- `ScriptDirective` は `obj.setanchor` を描画 API として検出します。
|
||||
- `NativeFieldMap` から未使用の `Epsilon` 定数を削除しました。
|
||||
- `AnchorSupportTests` と `SoftwareCompositorTests` を追加し、ネイティブ往復テストへ
|
||||
`blend`、`draw_state`、`setanchor`、`drawtarget` の検証を追加しました。
|
||||
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
Luaスクリプト for YMM4 v1.9.1
|
||||
Luaスクリプト for YMM4 v1.11.0
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、Luaスクリプトで映像エフェクトのパラメータや
|
||||
ピクセルを直接制御できるプラグインです。
|
||||
@@ -26,7 +26,9 @@ obj.x/y/zoom/alpha等の値はキーフレームアニメーションと連動
|
||||
|
||||
- スクリプトエラー時の挙動: コンパイルエラーまたは実行時エラーが発生した場合、
|
||||
そのフレームでの座標・透明度・回転・ピクセルの変更は適用されず、入力された
|
||||
元の状態がそのまま出力されます。エラー内容はログへ出力されます。
|
||||
元の状態がそのまま出力されます。エラー内容はログへ出力されるほか、スクリプト
|
||||
エディタの該当箇所へ赤い波線が表示され、ポイントするとエラー内容をツールチップ
|
||||
で確認できます。
|
||||
|
||||
- ファイルアクセスの制限: スクリプトからのファイル読み込みは許可されておらず、
|
||||
io・os等のモジュールも有効化されていません。
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Collections.Immutable;
|
||||
using LuaScript.Anchor;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AnchorSupportTests
|
||||
{
|
||||
[Fact]
|
||||
public void ClampCount_LimitsToRange()
|
||||
{
|
||||
Assert.Equal(0, AnchorSupport.ClampCount(-5));
|
||||
Assert.Equal(10, AnchorSupport.ClampCount(10));
|
||||
Assert.Equal(AnchorSupport.MaxAnchors, AnchorSupport.ClampCount(100));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyOption_SetsConnectionAndDimension()
|
||||
{
|
||||
var connection = AnchorConnection.None;
|
||||
bool is3D = false;
|
||||
|
||||
AnchorSupport.ApplyOption("loop", ref connection, ref is3D);
|
||||
AnchorSupport.ApplyOption("xyz", ref connection, ref is3D);
|
||||
|
||||
Assert.Equal(AnchorConnection.Loop, connection);
|
||||
Assert.True(is3D);
|
||||
|
||||
AnchorSupport.ApplyOption("star", ref connection, ref is3D);
|
||||
Assert.Equal(AnchorConnection.Star, connection);
|
||||
|
||||
AnchorSupport.ApplyOption("unknown", ref connection, ref is3D);
|
||||
Assert.Equal(AnchorConnection.Star, connection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultPosition_IsDeterministicGrid()
|
||||
{
|
||||
Assert.Equal(AnchorSupport.DefaultPosition(0), AnchorSupport.DefaultPosition(0));
|
||||
Assert.NotEqual(AnchorSupport.DefaultPosition(0), AnchorSupport.DefaultPosition(1));
|
||||
|
||||
var (x8, y8) = AnchorSupport.DefaultPosition(8);
|
||||
var (x0, y0) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(x0, x8);
|
||||
Assert.True(y8 > y0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePosition_PrefersStoredThenDefault()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "pos", Index = 1, X = 12, Y = 34, Z = 56 });
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "pos", 1, out double x, out double y, out double z);
|
||||
Assert.Equal(12, x);
|
||||
Assert.Equal(34, y);
|
||||
Assert.Equal(56, z);
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "pos", 0, out double dx, out double dy, out double dz);
|
||||
var (ex, ey) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(ex, dx);
|
||||
Assert.Equal(ey, dy);
|
||||
Assert.Equal(0, dz);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePosition_IsGroupScoped()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "a", Index = 0, X = 5, Y = 5, Z = 0 });
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "b", 0, out double x, out double y, out _);
|
||||
var (ex, ey) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(ex, x);
|
||||
Assert.Equal(ey, y);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDrag_UpdatesExistingPoint()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "pos", Index = 2, X = 10, Y = 20, Z = 30 });
|
||||
|
||||
var result = AnchorSupport.ApplyDrag(source, "pos", 2, 3, -4, 5);
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal(13, result[0].X);
|
||||
Assert.Equal(16, result[0].Y);
|
||||
Assert.Equal(35, result[0].Z);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDrag_AddsNewPointFromDefault()
|
||||
{
|
||||
var source = ImmutableList<LuaAnchorPoint>.Empty;
|
||||
|
||||
var result = AnchorSupport.ApplyDrag(source, "pos", 3, 7, 8, 0);
|
||||
|
||||
Assert.Single(result);
|
||||
var (bx, by) = AnchorSupport.DefaultPosition(3);
|
||||
Assert.Equal("pos", result[0].Group);
|
||||
Assert.Equal(3, result[0].Index);
|
||||
Assert.Equal(bx + 7, result[0].X);
|
||||
Assert.Equal(by + 8, result[0].Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using LuaScript.Compat;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AviUtlCompatMapTests
|
||||
{
|
||||
[Fact]
|
||||
public void Resolve_KnownEffect_ReturnsTargetType()
|
||||
{
|
||||
Assert.True(AviUtlCompatMap.Default.TryResolve("ぼかし", AviUtlEngine.AviUtl, out var mapping));
|
||||
Assert.Equal("GaussianBlurEffect", mapping.TargetType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_ParameterTransform_IsInverseOfExoExport()
|
||||
{
|
||||
AviUtlCompatMap.Default.TryResolve("ぼかし", AviUtlEngine.AviUtl, out var mapping);
|
||||
Assert.True(mapping.TryGetParameter("範囲", out var parameter));
|
||||
Assert.Equal("Blur", parameter.Property);
|
||||
Assert.Equal(5d, parameter.Transform(10d));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_AngleParameter_IsIdentity()
|
||||
{
|
||||
AviUtlCompatMap.Default.TryResolve("方向ブラー", AviUtlEngine.AviUtl, out var mapping);
|
||||
Assert.True(mapping.TryGetParameter("角度", out var parameter));
|
||||
Assert.Equal(45d, parameter.Transform(45d));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_BothEngine_MatchesAviUtl2()
|
||||
{
|
||||
Assert.True(AviUtlCompatMap.Default.TryResolve("クロマキー", AviUtlEngine.AviUtl2, out var mapping));
|
||||
Assert.Equal("ChromaKeyEffect", mapping.TargetType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_UndeclaredEffect_DoesNotResolve()
|
||||
{
|
||||
Assert.False(AviUtlCompatMap.Default.TryResolve("存在しないエフェクト", AviUtlEngine.AviUtl, out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveTarget_DefaultsToAviUtl()
|
||||
{
|
||||
Assert.Equal(AviUtlEngine.AviUtl, AviUtlCompatMap.ResolveTarget("obj.effect(\"ぼかし\", \"範囲\", 10)"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveTarget_DirectiveSelectsAviUtl2()
|
||||
{
|
||||
Assert.Equal(AviUtlEngine.AviUtl2, AviUtlCompatMap.ResolveTarget("--!aviutl2\nobj.effect(\"ぼかし\", \"範囲\", 10)"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Engine_BothIncludesEveryTarget()
|
||||
{
|
||||
Assert.True(AviUtlEngine.Both.Includes(AviUtlEngine.AviUtl));
|
||||
Assert.True(AviUtlEngine.Both.Includes(AviUtlEngine.AviUtl2));
|
||||
Assert.False(AviUtlEngine.AviUtl.Includes(AviUtlEngine.AviUtl2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,9 @@
|
||||
<Compile Include="..\LuaScript\Engine\LuaJitWorker.cs" Link="Linked\LuaJitWorker.cs" />
|
||||
<Compile Include="..\LuaScript\DrawCommand.cs" Link="Linked\DrawCommand.cs" />
|
||||
<Compile Include="..\LuaScript\DrawPolyMath.cs" Link="Linked\DrawPolyMath.cs" />
|
||||
<Compile Include="..\LuaScript\SoftwareCompositor.cs" Link="Linked\SoftwareCompositor.cs" />
|
||||
<Compile Include="..\LuaScript\Anchor\LuaAnchorPoint.cs" Link="Linked\LuaAnchorPoint.cs" />
|
||||
<Compile Include="..\LuaScript\Anchor\AnchorSupport.cs" Link="Linked\AnchorSupport.cs" />
|
||||
<Compile Include="..\LuaScript\SceneObjectInfo.cs" Link="Linked\SceneObjectInfo.cs" />
|
||||
<Compile Include="..\LuaScript\SceneObjectQuery.cs" Link="Linked\SceneObjectQuery.cs" />
|
||||
<Compile Include="..\LuaScript\AnimTableRegistrar.cs" Link="Linked\AnimTableRegistrar.cs" />
|
||||
@@ -41,6 +44,10 @@
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlParameterLayout.cs" Link="Linked\AviUtlParameterLayout.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\ScriptParameterUsage.cs" Link="Linked\ScriptParameterUsage.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlRandom.cs" Link="Linked\AviUtlRandom.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlEngine.cs" Link="Linked\AviUtlEngine.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlEffectMapping.cs" Link="Linked\AviUtlEffectMapping.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlCompatMap.cs" Link="Linked\AviUtlCompatMap.cs" />
|
||||
<EmbeddedResource Include="..\LuaScript\Compat\AviUtlCompatMap.xml" Link="Linked\AviUtlCompatMap.xml" />
|
||||
<Compile Include="..\LuaScript\Compat\FigureRenderer.cs" Link="Linked\FigureRenderer.cs" />
|
||||
<Compile Include="..\LuaScript\Engine\Kernel\KernelUnsupportedException.cs" Link="Linked\Kernel\KernelUnsupportedException.cs" />
|
||||
<Compile Include="..\LuaScript\Engine\Kernel\LuaToken.cs" Link="Linked\Kernel\LuaToken.cs" />
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace LuaScript.Tests
|
||||
private static readonly Func<string, double, (byte[] buffer, int w, int h)> NoLoadMovie = (_, _) => ([], 1, 1);
|
||||
private static readonly Action<string, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object>>> NoAddEffect = (_, _) => { };
|
||||
private static readonly Action<DrawCommand> NoAddDraw = _ => { };
|
||||
private static readonly Action<string, int, bool, int, double[]> NoSetAnchor = (_, _, _, _, _) => { };
|
||||
private static readonly System.Collections.Generic.IReadOnlyDictionary<string, string> NoStringParams = new System.Collections.Generic.Dictionary<string, string>();
|
||||
|
||||
private readonly LuaJitWorker _worker = new(NativeDir);
|
||||
|
||||
@@ -40,7 +42,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.rz = obj.time * 90\nobj.alpha = 128",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.False(dirty);
|
||||
@@ -48,6 +50,53 @@ namespace LuaScript.Tests
|
||||
Assert.Equal(128d, fields[NativeProtocol.Alpha]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringParameters_AreExposedOnObj()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var fields = Fields(2, 2, 0d);
|
||||
var pixels = new byte[16];
|
||||
var stringParameters = new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
["text"] = "hello",
|
||||
["file_image"] = "C:/サンプル/画像.png",
|
||||
};
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text) obj.alpha = string.len(obj.file_image)",
|
||||
fields, stringParameters, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(5d, fields[NativeProtocol.X]);
|
||||
Assert.Equal(System.Text.Encoding.UTF8.GetByteCount("C:/サンプル/画像.png"), fields[NativeProtocol.Alpha]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringParameters_GrowAndShrinkAroundCapacity()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
string big = new string('x', 100 * 1024);
|
||||
|
||||
var large = new System.Collections.Generic.Dictionary<string, string> { ["text"] = big };
|
||||
var fieldsLarge = Fields(2, 2, 0d);
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text)",
|
||||
fieldsLarge, large, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(big.Length, fieldsLarge[NativeProtocol.X]);
|
||||
|
||||
var small = new System.Collections.Generic.Dictionary<string, string> { ["text"] = "ok" };
|
||||
var fieldsSmall = Fields(2, 2, 0d);
|
||||
ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text)",
|
||||
fieldsSmall, small, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2d, fieldsSmall[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelScript_MatchesExpectedGrayscale()
|
||||
{
|
||||
@@ -75,7 +124,7 @@ namespace LuaScript.Tests
|
||||
"local gray = r*0.299 + g*0.587 + b*0.114 " +
|
||||
"obj.setpixel(x,y,gray,gray,gray,a) end end";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -110,7 +159,7 @@ namespace LuaScript.Tests
|
||||
"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";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -146,7 +195,7 @@ namespace LuaScript.Tests
|
||||
for (int k = 1; k <= 5; k++)
|
||||
{
|
||||
var fields = Fields(2, 2, k);
|
||||
bool ok = _worker.Execute("obj.x = obj.time * 10", fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.x = obj.time * 10", fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(k * 10d, fields[NativeProtocol.X]);
|
||||
}
|
||||
@@ -161,12 +210,12 @@ namespace LuaScript.Tests
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
bool timedOut = _worker.Execute(
|
||||
"local x=0 while true do x=x+1 end", fields, pixels, 2, 2, 1500, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
"local x=0 while true do x=x+1 end", fields, NoStringParams, pixels, 2, 2, 1500, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.False(timedOut);
|
||||
Assert.Contains("timed out", error);
|
||||
|
||||
var fields2 = Fields(2, 2, 3d);
|
||||
bool ok = _worker.Execute("obj.x = obj.time", fields2, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
bool ok = _worker.Execute("obj.x = obj.time", fields2, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(3d, fields2[NativeProtocol.X]);
|
||||
}
|
||||
@@ -188,7 +237,7 @@ namespace LuaScript.Tests
|
||||
"obj.zoom = o.zoom obj.rz = o.rz obj.alpha = o.alpha " +
|
||||
"obj.sx = o.sy obj.rzr = o.rzr";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(12d, fields[NativeProtocol.X]);
|
||||
@@ -220,13 +269,13 @@ namespace LuaScript.Tests
|
||||
"local b = obj.getobject(\"a\") " +
|
||||
"obj.x = a.x + b.x";
|
||||
|
||||
bool ok = _worker.Execute(script, Fields(2, 2, 0d), pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, Fields(2, 2, 0d), NoStringParams, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(1, calls);
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
x = 20d;
|
||||
ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
ok = _worker.Execute(script, fields, NoStringParams, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2, calls);
|
||||
Assert.Equal(40d, fields[NativeProtocol.X]);
|
||||
@@ -243,7 +292,7 @@ namespace LuaScript.Tests
|
||||
const string script =
|
||||
"local o = obj.getobject(\"missing\") obj.x = o == nil and 1 or 0";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(1d, fields[NativeProtocol.X]);
|
||||
@@ -261,7 +310,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.draw(10, 20, 30, 2, 0.5, 0.25)",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -282,7 +331,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.drawpoly(0,0,0, 10,0,0, 10,10,0, 0,10,0)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -304,7 +353,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.drawpoly(0,0,0, 8,0,0, 8,8,0, 0,8,0, 1,1, 3,1, 3,3, 1,3, 0.5)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -325,7 +374,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setoption('antialias', 0) obj.x = obj.getoption('antialias') obj.y = obj.getoption('unset')",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -344,7 +393,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.setoption('antialias', 0) obj.draw()",
|
||||
Fields(2, 2, 0d), pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
Fields(2, 2, 0d), NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -353,6 +402,157 @@ namespace LuaScript.Tests
|
||||
Assert.Equal(0d, commands[1].Antialias);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Draw_CarriesBlendFromOption()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
var commands = new System.Collections.Generic.List<DrawCommand>();
|
||||
Action<DrawCommand> addDraw = commands.Add;
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.setoption('blend', 3) obj.draw()",
|
||||
Fields(2, 2, 0d), NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2, commands.Count);
|
||||
Assert.Equal(0d, commands[0].Blend);
|
||||
Assert.Equal(3d, commands[1].Blend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawPoly_CarriesBlendFromOption()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[4 * 4 * 4];
|
||||
var commands = new System.Collections.Generic.List<DrawCommand>();
|
||||
Action<DrawCommand> addDraw = commands.Add;
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setoption('blend', 11) obj.drawpoly(0,0,0, 10,0,0, 10,10,0, 0,10,0)",
|
||||
Fields(4, 4, 0d), NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Single(commands);
|
||||
Assert.Equal(11d, commands[0].Blend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOption_DrawState_WritesBackFlag()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
|
||||
var fTrue = Fields(2, 2, 0d);
|
||||
bool okTrue = _worker.Execute(
|
||||
"obj.setoption('draw_state', true)",
|
||||
fTrue, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorTrue);
|
||||
Assert.True(okTrue, errorTrue);
|
||||
Assert.Equal(1d, fTrue[NativeProtocol.DrawState]);
|
||||
|
||||
var fFalse = Fields(2, 2, 0d);
|
||||
bool okFalse = _worker.Execute(
|
||||
"obj.setoption('draw_state', false)",
|
||||
fFalse, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorFalse);
|
||||
Assert.True(okFalse, errorFalse);
|
||||
Assert.Equal(2d, fFalse[NativeProtocol.DrawState]);
|
||||
|
||||
var fUnset = Fields(2, 2, 0d);
|
||||
bool okUnset = _worker.Execute(
|
||||
"obj.x = 1",
|
||||
fUnset, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorUnset);
|
||||
Assert.True(okUnset, errorUnset);
|
||||
Assert.Equal(0d, fUnset[NativeProtocol.DrawState]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetAnchor_FillsLuaVariableFromResolver()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
string? capturedGroup = null;
|
||||
int capturedCount = -1;
|
||||
Action<string, int, bool, int, double[]> setAnchor = (group, count, is3D, connection, positions) =>
|
||||
{
|
||||
capturedGroup = group;
|
||||
capturedCount = count;
|
||||
int stride = is3D ? 3 : 2;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
positions[i * stride + 0] = i * 10;
|
||||
positions[i * stride + 1] = i * 10 + 5;
|
||||
if (is3D)
|
||||
positions[i * stride + 2] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
string script =
|
||||
"local n = obj.setanchor('pos', 2, 'loop')\n" +
|
||||
"obj.x = n\n" +
|
||||
"obj.y = pos[1]\n" +
|
||||
"obj.z = pos[3]";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, 2, 2, 5000,
|
||||
NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, setAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal("pos", capturedGroup);
|
||||
Assert.Equal(2, capturedCount);
|
||||
Assert.Equal(2d, fields[NativeProtocol.X]);
|
||||
Assert.Equal(0d, fields[NativeProtocol.Y]);
|
||||
Assert.Equal(10d, fields[NativeProtocol.Z]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawTarget_TempBuffer_CompositesAndCopiesBack()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[2 * 2 * 4];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
string script =
|
||||
"obj.setpixel(0,0,255,0,0,255)\n" +
|
||||
"obj.setpixel(1,0,0,255,0,255)\n" +
|
||||
"obj.setpixel(0,1,0,0,255,255)\n" +
|
||||
"obj.setpixel(1,1,255,255,0,255)\n" +
|
||||
"obj.setoption('drawtarget','tempbuffer',2,2)\n" +
|
||||
"obj.draw(1,1,0,1,1,0)\n" +
|
||||
"obj.setoption('drawtarget','framebuffer')\n" +
|
||||
"obj.copybuffer('obj','tmp')";
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
script, fields, NoStringParams, pixels, 2, 2, 5000,
|
||||
NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
|
||||
Assert.Equal(0, pixels[0]);
|
||||
Assert.Equal(0, pixels[1]);
|
||||
Assert.Equal(255, pixels[2]);
|
||||
Assert.Equal(255, pixels[3]);
|
||||
|
||||
int i11 = (1 * 2 + 1) * 4;
|
||||
Assert.Equal(0, pixels[i11]);
|
||||
Assert.Equal(255, pixels[i11 + 1]);
|
||||
Assert.Equal(255, pixels[i11 + 2]);
|
||||
Assert.Equal(255, pixels[i11 + 3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadText_RoundTripsThroughCallback()
|
||||
{
|
||||
@@ -381,7 +581,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setfont('Meiryo', 40, 3, 0x112233) obj.load('text', 'Hi')",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, loadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, loadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -421,7 +621,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.load('image', 'C:/sample.png')",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, loadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, loadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -458,7 +658,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.load('movie', 'C:/clip.mp4', 1.5)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, loadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, loadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -483,7 +683,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = obj.getvalue('track0') obj.y = obj.getvalue('alpha') obj.z = obj.getvalue('unknown')",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -510,7 +710,7 @@ namespace LuaScript.Tests
|
||||
"for y=0,obj.h-1 do for x=0,obj.w-1 do obj.setpixel(x,y,0,0,0,0) end end " +
|
||||
"obj.copybuffer('obj','tmp')";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -529,11 +729,11 @@ namespace LuaScript.Tests
|
||||
stored[3] = 255; stored[7] = 255; stored[11] = 255; stored[15] = 255;
|
||||
|
||||
var save = (byte[])stored.Clone();
|
||||
bool ok = _worker.Execute("obj.copybuffer('cache:foo','obj')", Fields(w, h, 0d), save, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.copybuffer('cache:foo','obj')", Fields(w, h, 0d), NoStringParams, save, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
|
||||
var blank = new byte[w * h * 4];
|
||||
ok = _worker.Execute("obj.copybuffer('obj','cache:foo')", Fields(w, h, 0d), blank, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out error);
|
||||
ok = _worker.Execute("obj.copybuffer('obj','cache:foo')", Fields(w, h, 0d), NoStringParams, blank, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
Assert.Equal(stored, blank);
|
||||
@@ -547,12 +747,12 @@ namespace LuaScript.Tests
|
||||
var pixels = new byte[16];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
bool ok = _worker.Execute("obj.x = missing.value", fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.x = missing.value", fields, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.False(ok);
|
||||
Assert.False(string.IsNullOrEmpty(error));
|
||||
|
||||
var fields2 = Fields(2, 2, 7d);
|
||||
bool ok2 = _worker.Execute("obj.x = obj.time", fields2, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
bool ok2 = _worker.Execute("obj.x = obj.time", fields2, NoStringParams, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok2, error);
|
||||
Assert.Equal(7d, fields2[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
using LuaScript;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class SoftwareCompositorTests
|
||||
{
|
||||
private static byte[] Solid(int w, int h, byte b, byte g, byte r, byte a)
|
||||
{
|
||||
var buffer = new byte[w * h * 4];
|
||||
for (int i = 0; i < w * h; i++)
|
||||
{
|
||||
buffer[i * 4] = b;
|
||||
buffer[i * 4 + 1] = g;
|
||||
buffer[i * 4 + 2] = r;
|
||||
buffer[i * 4 + 3] = a;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_NearestOpaque_BlitsSinglePixel()
|
||||
{
|
||||
var dst = new byte[3 * 3 * 4];
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 3, 3, src, 1, 1, 1.5, 1.5, 1d, 0d, 1d, linear: false);
|
||||
|
||||
int center = (1 * 3 + 1) * 4;
|
||||
Assert.Equal(255, dst[center]);
|
||||
Assert.Equal(255, dst[center + 1]);
|
||||
Assert.Equal(255, dst[center + 2]);
|
||||
Assert.Equal(255, dst[center + 3]);
|
||||
|
||||
Assert.Equal(0, dst[0]);
|
||||
Assert.Equal(0, dst[(0 * 3 + 0) * 4 + 3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_HalfAlphaOverOpaque_BlendsPremultiplied()
|
||||
{
|
||||
var dst = Solid(1, 1, 0, 0, 0, 255);
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 1, 1, src, 1, 1, 0.5, 0.5, 1d, 0d, 0.5, linear: false);
|
||||
|
||||
Assert.Equal(127, dst[0]);
|
||||
Assert.Equal(127, dst[1]);
|
||||
Assert.Equal(127, dst[2]);
|
||||
Assert.Equal(255, dst[3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_OutOfBounds_LeavesDestinationUnchanged()
|
||||
{
|
||||
var dst = new byte[2 * 2 * 4];
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 2, 2, src, 1, 1, 100d, 100d, 1d, 0d, 1d, linear: false);
|
||||
|
||||
foreach (var value in dst)
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawPolyInto_IdentityAffine_CopiesSource()
|
||||
{
|
||||
var src = new byte[2 * 2 * 4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
src[i * 4] = (byte)(i + 1);
|
||||
src[i * 4 + 1] = (byte)(i + 10);
|
||||
src[i * 4 + 2] = (byte)(i + 20);
|
||||
src[i * 4 + 3] = 255;
|
||||
}
|
||||
var dst = new byte[2 * 2 * 4];
|
||||
|
||||
double[] poly =
|
||||
[
|
||||
0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 0,
|
||||
0, 0, 2, 0, 2, 2, 0, 2,
|
||||
1,
|
||||
];
|
||||
|
||||
SoftwareCompositor.DrawPolyInto(dst, 2, 2, src, 2, 2, poly, 1d, linear: false);
|
||||
|
||||
Assert.Equal(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace LuaScript.Anchor
|
||||
{
|
||||
internal enum AnchorConnection
|
||||
{
|
||||
None,
|
||||
Line,
|
||||
Loop,
|
||||
Star,
|
||||
Arm,
|
||||
}
|
||||
|
||||
internal readonly record struct AnchorOptions(AnchorConnection Connection, bool Is3D);
|
||||
|
||||
internal readonly record struct AnchorRequestData(string Group, int Count, AnchorConnection Connection, bool Is3D);
|
||||
|
||||
internal static class AnchorSupport
|
||||
{
|
||||
public const int MaxAnchors = 32;
|
||||
public const string TrackGroup = "track";
|
||||
|
||||
public static int ClampCount(int count) => Math.Clamp(count, 0, MaxAnchors);
|
||||
|
||||
public static void ApplyOption(string option, ref AnchorConnection connection, ref bool is3D)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case "line": connection = AnchorConnection.Line; break;
|
||||
case "loop": connection = AnchorConnection.Loop; break;
|
||||
case "star": connection = AnchorConnection.Star; break;
|
||||
case "arm": connection = AnchorConnection.Arm; break;
|
||||
case "xyz": is3D = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
public static (double X, double Y) DefaultPosition(int index)
|
||||
{
|
||||
int col = index % 8;
|
||||
int row = index / 8;
|
||||
return ((col - 3.5) * 60d, (row - 1.5) * 60d);
|
||||
}
|
||||
|
||||
public static void ResolvePosition(IReadOnlyList<LuaAnchorPoint>? source, string group, int index,
|
||||
out double x, out double y, out double z)
|
||||
{
|
||||
if (source is not null)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
var a = source[i];
|
||||
if (a.Index == index && string.Equals(a.Group, group, StringComparison.Ordinal))
|
||||
{
|
||||
x = a.X;
|
||||
y = a.Y;
|
||||
z = a.Z;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var (dx, dy) = DefaultPosition(index);
|
||||
x = dx;
|
||||
y = dy;
|
||||
z = 0d;
|
||||
}
|
||||
|
||||
public static ImmutableList<LuaAnchorPoint> ApplyDrag(
|
||||
ImmutableList<LuaAnchorPoint> source, string group, int index, double dx, double dy, double dz)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
var a = source[i];
|
||||
if (a.Index == index && string.Equals(a.Group, group, StringComparison.Ordinal))
|
||||
{
|
||||
return source.SetItem(i, new LuaAnchorPoint
|
||||
{
|
||||
Group = group,
|
||||
Index = index,
|
||||
X = a.X + dx,
|
||||
Y = a.Y + dy,
|
||||
Z = a.Z + dz,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var (bx, by) = DefaultPosition(index);
|
||||
return source.Add(new LuaAnchorPoint
|
||||
{
|
||||
Group = group,
|
||||
Index = index,
|
||||
X = bx + dx,
|
||||
Y = by + dy,
|
||||
Z = dz,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace LuaScript.Anchor
|
||||
{
|
||||
public sealed class LuaAnchorPoint
|
||||
{
|
||||
public string Group { get; set; } = string.Empty;
|
||||
public int Index { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Z { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,19 @@
|
||||
using LuaScript.Anchor;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal sealed class AviUtlScriptContext
|
||||
{
|
||||
public IReadOnlyList<LuaAnchorPoint>? AnchorSource { get; set; }
|
||||
|
||||
private readonly List<AnchorRequestData> _anchorRequests = [];
|
||||
|
||||
public IReadOnlyList<AnchorRequestData> AnchorRequests => _anchorRequests;
|
||||
|
||||
internal void AddAnchorRequest(in AnchorRequestData request) => _anchorRequests.Add(request);
|
||||
|
||||
internal void ClearAnchorRequests() => _anchorRequests.Clear();
|
||||
|
||||
public bool IsPlaying { get; set; }
|
||||
public bool IsPaused { get; set; }
|
||||
public string SceneId { get; set; } = string.Empty;
|
||||
@@ -29,6 +41,11 @@ namespace LuaScript
|
||||
public double Track2 { get; set; }
|
||||
public double Track3 { get; set; }
|
||||
|
||||
public double Slider0 { get; set; }
|
||||
public double Slider1 { get; set; }
|
||||
public double Slider2 { get; set; }
|
||||
public double Slider3 { get; set; }
|
||||
|
||||
public bool Check0 { get; set; }
|
||||
public bool Check1 { get; set; }
|
||||
public bool Check2 { get; set; }
|
||||
@@ -37,6 +54,8 @@ namespace LuaScript
|
||||
public bool HasColor { get; set; }
|
||||
public double ColorValue { get; set; }
|
||||
|
||||
public bool? DrawStateOverride { get; set; }
|
||||
|
||||
public double Time { get; set; }
|
||||
public int Frame { get; set; }
|
||||
public int TotalFrame { get; set; }
|
||||
@@ -52,6 +71,12 @@ namespace LuaScript
|
||||
|
||||
public Func<SceneObjectResolver>? ResolverProvider { get; set; }
|
||||
|
||||
private readonly Dictionary<string, string> _stringParameters = new(StringComparer.Ordinal);
|
||||
|
||||
public IReadOnlyDictionary<string, string> StringParameters => _stringParameters;
|
||||
|
||||
internal void SetStringParameter(string name, string? value) => _stringParameters[name] = value ?? string.Empty;
|
||||
|
||||
private const double Epsilon = 1e-10;
|
||||
|
||||
private readonly List<SceneObjectQuery> _objectQueries = [];
|
||||
@@ -74,6 +99,53 @@ namespace LuaScript
|
||||
|
||||
internal void ClearDraws() => _drawCommands.Clear();
|
||||
|
||||
private bool _drawTargetTemp;
|
||||
|
||||
internal void ResetDrawTarget() => _drawTargetTemp = false;
|
||||
|
||||
internal void SetDrawTarget(bool temp, int width, int height, bool hasSize)
|
||||
{
|
||||
_drawTargetTemp = temp;
|
||||
if (temp && hasSize)
|
||||
{
|
||||
int w = Math.Max(1, width);
|
||||
int h = Math.Max(1, height);
|
||||
_buffers["t"] = (new byte[w * h * 4], w, h);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SubmitDraw(DrawCommand command)
|
||||
{
|
||||
if (!_drawTargetTemp)
|
||||
{
|
||||
_drawCommands.Add(command);
|
||||
return;
|
||||
}
|
||||
CompositeToTemp(command);
|
||||
}
|
||||
|
||||
private void CompositeToTemp(DrawCommand command)
|
||||
{
|
||||
EnsurePixelBuffer();
|
||||
var src = _pixelBuffer;
|
||||
if (src is null)
|
||||
return;
|
||||
|
||||
if (!_buffers.TryGetValue("t", out var temp))
|
||||
{
|
||||
int w = Math.Max(1, ImageWidth);
|
||||
int h = Math.Max(1, ImageHeight);
|
||||
temp = (new byte[w * h * 4], w, h);
|
||||
_buffers["t"] = temp;
|
||||
}
|
||||
|
||||
bool linear = command.Antialias != 0d;
|
||||
if (command.Poly is { } poly)
|
||||
SoftwareCompositor.DrawPolyInto(temp.Data, temp.Width, temp.Height, src, ImageWidth, ImageHeight, poly, command.Alpha, linear);
|
||||
else
|
||||
SoftwareCompositor.DrawInto(temp.Data, temp.Width, temp.Height, src, ImageWidth, ImageHeight, command.Ox, command.Oy, command.Zoom, command.Aspect, command.Alpha, linear);
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, (byte[] Data, int Width, int Height)> _buffers = new(StringComparer.Ordinal);
|
||||
|
||||
internal bool CopyBuffer(string dst, string src)
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal sealed class AviUtlCompatMap
|
||||
{
|
||||
private const string ResourceSuffix = "AviUtlCompatMap.xml";
|
||||
|
||||
private readonly Dictionary<string, List<AviUtlEffectMapping>> _effects;
|
||||
|
||||
public static AviUtlCompatMap Default { get; } = Load();
|
||||
|
||||
private AviUtlCompatMap(Dictionary<string, List<AviUtlEffectMapping>> effects)
|
||||
{
|
||||
_effects = effects;
|
||||
}
|
||||
|
||||
public bool TryResolve(string name, AviUtlEngine target, out AviUtlEffectMapping mapping)
|
||||
{
|
||||
mapping = null!;
|
||||
if (string.IsNullOrEmpty(name) || !_effects.TryGetValue(Normalize(name), out var candidates))
|
||||
return false;
|
||||
|
||||
foreach (var candidate in candidates)
|
||||
{
|
||||
if (candidate.Engine.Includes(target))
|
||||
{
|
||||
mapping = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AviUtlEngine ResolveTarget(string? script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(script))
|
||||
return AviUtlEngine.AviUtl;
|
||||
|
||||
foreach (var raw in script.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n'))
|
||||
{
|
||||
var line = raw.Trim();
|
||||
if (!line.StartsWith("--!", System.StringComparison.Ordinal))
|
||||
continue;
|
||||
var token = line[3..].Trim().ToLowerInvariant();
|
||||
if (token == "aviutl2")
|
||||
return AviUtlEngine.AviUtl2;
|
||||
if (token == "aviutl")
|
||||
return AviUtlEngine.AviUtl;
|
||||
}
|
||||
return AviUtlEngine.AviUtl;
|
||||
}
|
||||
|
||||
private static AviUtlCompatMap Load()
|
||||
{
|
||||
var effects = new Dictionary<string, List<AviUtlEffectMapping>>(StringComparer.OrdinalIgnoreCase);
|
||||
try
|
||||
{
|
||||
using var stream = OpenResource();
|
||||
if (stream is not null)
|
||||
Populate(effects, stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return new AviUtlCompatMap(effects);
|
||||
}
|
||||
|
||||
private static void Populate(Dictionary<string, List<AviUtlEffectMapping>> effects, Stream stream)
|
||||
{
|
||||
var root = XDocument.Load(stream).Root;
|
||||
if (root is null)
|
||||
return;
|
||||
|
||||
foreach (var element in root.Elements("effect"))
|
||||
{
|
||||
var target = (string?)element.Attribute("target");
|
||||
if (string.IsNullOrWhiteSpace(target))
|
||||
continue;
|
||||
|
||||
if (!AviUtlEngineExtensions.TryParse(((string?)element.Attribute("engine"))?.Trim().ToLowerInvariant(), out var engine))
|
||||
engine = AviUtlEngine.Both;
|
||||
|
||||
var parameters = element.Elements("param").Select(ParseParameter).ToArray();
|
||||
var mapping = new AviUtlEffectMapping(engine, target.Trim(), parameters);
|
||||
|
||||
foreach (var name in SplitNames((string?)element.Attribute("names")))
|
||||
{
|
||||
if (!effects.TryGetValue(name, out var list))
|
||||
{
|
||||
list = [];
|
||||
effects[name] = list;
|
||||
}
|
||||
list.Add(mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static AviUtlParameterMapping ParseParameter(XElement element)
|
||||
{
|
||||
var source = ((string?)element.Attribute("name") ?? string.Empty).Trim();
|
||||
var property = ((string?)element.Attribute("property") ?? string.Empty).Trim();
|
||||
double scale = ParseDouble((string?)element.Attribute("scale"), 1d);
|
||||
double offset = ParseDouble((string?)element.Attribute("offset"), 0d);
|
||||
return new AviUtlParameterMapping(source, property, scale, offset);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> SplitNames(string? names)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(names))
|
||||
yield break;
|
||||
foreach (var part in names.Split(','))
|
||||
{
|
||||
var trimmed = part.Trim();
|
||||
if (trimmed.Length != 0)
|
||||
yield return Normalize(trimmed);
|
||||
}
|
||||
}
|
||||
|
||||
private static double ParseDouble(string? value, double fallback) =>
|
||||
double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out double result) ? result : fallback;
|
||||
|
||||
private static string Normalize(string value) => value.Trim().ToLowerInvariant();
|
||||
|
||||
private static Stream? OpenResource()
|
||||
{
|
||||
var assembly = typeof(AviUtlCompatMap).Assembly;
|
||||
var name = assembly.GetManifestResourceNames()
|
||||
.FirstOrDefault(n => n.EndsWith(ResourceSuffix, System.StringComparison.Ordinal));
|
||||
return name is null ? null : assembly.GetManifestResourceStream(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<aviUtlCompat>
|
||||
<effect engine="both" names="ぼかし" target="GaussianBlurEffect">
|
||||
<param name="範囲" property="Blur" scale="0.5" />
|
||||
<param name="サイズ固定" property="IsHardBorderMode" />
|
||||
</effect>
|
||||
<effect engine="both" names="境界ぼかし" target="BorderBlurEffect">
|
||||
<param name="範囲" property="Blur" />
|
||||
</effect>
|
||||
<effect engine="both" names="方向ブラー" target="DirectionalBlurEffect">
|
||||
<param name="範囲" property="StandardDeviation" scale="0.5" />
|
||||
<param name="角度" property="Angle" />
|
||||
<param name="サイズ固定" property="IsHardBorderMode" />
|
||||
</effect>
|
||||
<effect engine="both" names="放射ブラー" target="RadialBlurEffect">
|
||||
<param name="範囲" property="Blur" />
|
||||
<param name="X" property="X" />
|
||||
<param name="Y" property="Y" />
|
||||
<param name="サイズを固定" property="IsHardBorderMode" />
|
||||
</effect>
|
||||
<effect engine="both" names="閃光" target="RadialLightEffect">
|
||||
<param name="範囲" property="Value" />
|
||||
<param name="X" property="X" />
|
||||
<param name="Y" property="Y" />
|
||||
<param name="サイズを固定" property="IsHardBorderMode" />
|
||||
</effect>
|
||||
<effect engine="both" names="クロマキー" target="ChromaKeyEffect">
|
||||
<param name="色相範囲" property="Tolerance" scale="0.390625" />
|
||||
<param name="境界補正" property="Feather" />
|
||||
</effect>
|
||||
<effect engine="both" names="クリッピング" target="CropEffect">
|
||||
<param name="上" property="Top" />
|
||||
<param name="下" property="Bottom" />
|
||||
<param name="左" property="Left" />
|
||||
<param name="右" property="Right" />
|
||||
<param name="中心の位置を変更" property="IsCentering" />
|
||||
</effect>
|
||||
<effect engine="both" names="斜めクリッピング" target="CropByAngleEffect">
|
||||
<param name="中心X" property="X" />
|
||||
<param name="中心Y" property="Y" />
|
||||
<param name="角度" property="Angle" />
|
||||
<param name="ぼかし" property="Blur" scale="0.5" />
|
||||
<param name="幅" property="Width" />
|
||||
</effect>
|
||||
<effect engine="both" names="領域拡張" target="MarginEffect">
|
||||
<param name="上" property="Top" />
|
||||
<param name="下" property="Bottom" />
|
||||
<param name="左" property="Left" />
|
||||
<param name="右" property="Right" />
|
||||
</effect>
|
||||
<effect engine="both" names="座標" target="DrawPositionEffect">
|
||||
<param name="X" property="X" />
|
||||
<param name="Y" property="Y" />
|
||||
<param name="Z" property="Z" />
|
||||
</effect>
|
||||
<effect engine="both" names="回転" target="RotateEffect">
|
||||
<param name="X" property="X" />
|
||||
<param name="Y" property="Y" />
|
||||
<param name="Z" property="Z" />
|
||||
</effect>
|
||||
<effect engine="both" names="リサイズ" target="ZoomEffect">
|
||||
<param name="拡大率" property="Zoom" />
|
||||
<param name="X" property="ZoomX" />
|
||||
<param name="Y" property="ZoomY" />
|
||||
<param name="補間なし" property="IsNearestNeighbor" />
|
||||
</effect>
|
||||
<effect engine="both" names="画像ループ" target="TilingEffect">
|
||||
<param name="横回数" property="X" />
|
||||
<param name="縦回数" property="Y" />
|
||||
</effect>
|
||||
<effect engine="both" names="極座標変換" target="PolarTransformEffect">
|
||||
<param name="中心幅" property="CoreWidth" />
|
||||
<param name="渦巻" property="TwistAngle" scale="360" />
|
||||
</effect>
|
||||
<effect engine="both" names="グラデーション" target="GradientEffect">
|
||||
<param name="強さ" property="Opacity" />
|
||||
<param name="中心X" property="X" />
|
||||
<param name="中心Y" property="Y" />
|
||||
<param name="角度" property="Rotation" />
|
||||
<param name="幅" property="Size" />
|
||||
</effect>
|
||||
<effect engine="both" names="単色化" target="MonocolorizationEffect">
|
||||
<param name="強さ" property="Strength" />
|
||||
<param name="輝度を保持する" property="KeepBrightness" />
|
||||
</effect>
|
||||
<effect engine="both" names="縁取り" target="OutlineEffect">
|
||||
<param name="サイズ" property="StrokeThickness" />
|
||||
<param name="ぼかし" property="Blur" />
|
||||
</effect>
|
||||
<effect engine="both" names="反転" target="InvertEffect" />
|
||||
<effect engine="both" names="モザイク" target="MosaicEffect">
|
||||
<param name="サイズ" property="Size" />
|
||||
</effect>
|
||||
<effect engine="both" names="ディスプレイスメントマップ" target="DisplacementMapEffect">
|
||||
<param name="ぼかし" property="Blur" scale="0.5" />
|
||||
</effect>
|
||||
<effect engine="both" names="動画ファイル合成" target="TextureEffect">
|
||||
<param name="X" property="X" />
|
||||
<param name="Y" property="Y" />
|
||||
<param name="拡大率" property="Zoom" />
|
||||
</effect>
|
||||
<effect engine="both" names="色調補正" target="ColorCorrectionEffect">
|
||||
<param name="明るさ" property="Lightness" />
|
||||
<param name="コントラスト" property="Contrast" />
|
||||
<param name="色相" property="HueRotation" />
|
||||
<param name="輝度" property="Brightness" />
|
||||
<param name="彩度" property="Saturation" />
|
||||
</effect>
|
||||
<effect engine="both" names="色ずれ" target="ColorShiftEffect">
|
||||
<param name="ずれ幅" property="Shift" />
|
||||
<param name="角度" property="Angle" />
|
||||
<param name="強さ" property="Strength" />
|
||||
</effect>
|
||||
</aviUtlCompat>
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal readonly record struct AviUtlParameterMapping(string Source, string Property, double Scale, double Offset)
|
||||
{
|
||||
public double Transform(double value) => value * Scale + Offset;
|
||||
}
|
||||
|
||||
internal sealed class AviUtlEffectMapping
|
||||
{
|
||||
private readonly Dictionary<string, AviUtlParameterMapping> _parameters;
|
||||
|
||||
public AviUtlEngine Engine { get; }
|
||||
|
||||
public string TargetType { get; }
|
||||
|
||||
public AviUtlEffectMapping(AviUtlEngine engine, string targetType, IEnumerable<AviUtlParameterMapping> parameters)
|
||||
{
|
||||
Engine = engine;
|
||||
TargetType = targetType;
|
||||
_parameters = new Dictionary<string, AviUtlParameterMapping>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var parameter in parameters)
|
||||
_parameters[parameter.Source] = parameter;
|
||||
}
|
||||
|
||||
public bool TryGetParameter(string source, out AviUtlParameterMapping mapping) =>
|
||||
_parameters.TryGetValue(source, out mapping);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal enum AviUtlEngine
|
||||
{
|
||||
AviUtl,
|
||||
AviUtl2,
|
||||
Both,
|
||||
}
|
||||
|
||||
internal static class AviUtlEngineExtensions
|
||||
{
|
||||
public static bool Includes(this AviUtlEngine scope, AviUtlEngine target) =>
|
||||
scope == AviUtlEngine.Both || scope == target;
|
||||
|
||||
public static bool TryParse(string? value, out AviUtlEngine engine)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case "aviutl":
|
||||
engine = AviUtlEngine.AviUtl;
|
||||
return true;
|
||||
case "aviutl2":
|
||||
engine = AviUtlEngine.AviUtl2;
|
||||
return true;
|
||||
case "both":
|
||||
engine = AviUtlEngine.Both;
|
||||
return true;
|
||||
default:
|
||||
engine = AviUtlEngine.AviUtl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,12 @@ namespace LuaScript.Compat
|
||||
Param,
|
||||
}
|
||||
|
||||
public static string Transform(string source)
|
||||
public static string Transform(string source) => TransformWithMap(source).Code;
|
||||
|
||||
public static (string Code, int[] LineMap) TransformWithMap(string source)
|
||||
{
|
||||
if (string.IsNullOrEmpty(source))
|
||||
return source;
|
||||
return (source, []);
|
||||
|
||||
var lines = source.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
|
||||
@@ -48,15 +50,24 @@ namespace LuaScript.Compat
|
||||
AppendDeclarations(lines[i], prelude);
|
||||
|
||||
if (!hasSection && prelude.Count == 0)
|
||||
return source;
|
||||
return (source, []);
|
||||
|
||||
var builder = new StringBuilder(source.Length + 64);
|
||||
foreach (var declaration in prelude)
|
||||
builder.Append(declaration).Append('\n');
|
||||
for (int i = sectionStart; i < sectionEnd; i++)
|
||||
builder.Append(lines[i]).Append('\n');
|
||||
var lineMap = new int[prelude.Count + (sectionEnd - sectionStart)];
|
||||
int row = 0;
|
||||
|
||||
return builder.ToString();
|
||||
foreach (var declaration in prelude)
|
||||
{
|
||||
builder.Append(declaration).Append('\n');
|
||||
lineMap[row++] = -1;
|
||||
}
|
||||
for (int i = sectionStart; i < sectionEnd; i++)
|
||||
{
|
||||
builder.Append(lines[i]).Append('\n');
|
||||
lineMap[row++] = i;
|
||||
}
|
||||
|
||||
return (builder.ToString(), lineMap);
|
||||
}
|
||||
|
||||
private static void AppendDeclarations(string line, List<string> prelude)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using YukkuriMovieMaker.Project;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal static class BlendModeMap
|
||||
{
|
||||
private static readonly Blend[] Order =
|
||||
[
|
||||
Blend.Normal,
|
||||
Blend.Dissolve,
|
||||
Blend.Darker,
|
||||
Blend.Multiply,
|
||||
Blend.ColorBurn,
|
||||
Blend.LinearBurn,
|
||||
Blend.Lighter,
|
||||
Blend.Screen,
|
||||
Blend.ColorDodge,
|
||||
Blend.LinearDodge,
|
||||
Blend.Add,
|
||||
Blend.Overlay,
|
||||
Blend.SoftLight,
|
||||
Blend.HardLight,
|
||||
Blend.VividLight,
|
||||
Blend.LinearLight,
|
||||
Blend.PinLight,
|
||||
Blend.HardMix,
|
||||
Blend.Difference,
|
||||
Blend.Exclusion,
|
||||
Blend.Subtract,
|
||||
Blend.Division,
|
||||
Blend.Hue,
|
||||
Blend.Saturation,
|
||||
Blend.Color,
|
||||
Blend.Luminosity,
|
||||
Blend.LighterColor,
|
||||
Blend.DestinationOver,
|
||||
Blend.DarkerColor,
|
||||
Blend.DestinationOut,
|
||||
Blend.SourceAtop,
|
||||
Blend.XOR,
|
||||
Blend.MaskInvert,
|
||||
];
|
||||
|
||||
public static Blend Resolve(double value)
|
||||
{
|
||||
if (double.IsNaN(value))
|
||||
return Blend.Normal;
|
||||
|
||||
int index = (int)value;
|
||||
return (uint)index < (uint)Order.Length ? Order[index] : Blend.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,31 +6,29 @@ namespace LuaScript.Compat
|
||||
{
|
||||
internal readonly struct ScriptParameterUsage
|
||||
{
|
||||
public bool Check0 { get; }
|
||||
public bool Check1 { get; }
|
||||
public bool Check2 { get; }
|
||||
public bool Check3 { get; }
|
||||
public bool Color { get; }
|
||||
private readonly HashSet<string>? _members;
|
||||
private readonly bool _color;
|
||||
|
||||
private ScriptParameterUsage(bool check0, bool check1, bool check2, bool check3, bool color)
|
||||
private ScriptParameterUsage(HashSet<string>? members, bool color)
|
||||
{
|
||||
Check0 = check0;
|
||||
Check1 = check1;
|
||||
Check2 = check2;
|
||||
Check3 = check3;
|
||||
Color = color;
|
||||
_members = members;
|
||||
_color = color;
|
||||
}
|
||||
|
||||
public static readonly ScriptParameterUsage None = default;
|
||||
|
||||
public bool Check(int index) => index switch
|
||||
{
|
||||
0 => Check0,
|
||||
1 => Check1,
|
||||
2 => Check2,
|
||||
3 => Check3,
|
||||
_ => false,
|
||||
};
|
||||
public bool Color => _color;
|
||||
|
||||
public bool Uses(string member) => _members is not null && _members.Contains(member);
|
||||
|
||||
public bool Check0 => Uses("check0");
|
||||
public bool Check1 => Uses("check1");
|
||||
public bool Check2 => Uses("check2");
|
||||
public bool Check3 => Uses("check3");
|
||||
|
||||
public bool Check(int index) => (uint)index < 4 && Uses("check" + (char)('0' + index));
|
||||
|
||||
public bool Slider(int index) => (uint)index < 4 && Uses("slider" + (char)('0' + index));
|
||||
|
||||
public static ScriptParameterUsage Detect(string? script)
|
||||
{
|
||||
@@ -47,7 +45,7 @@ namespace LuaScript.Compat
|
||||
return None;
|
||||
}
|
||||
|
||||
var checks = new bool[4];
|
||||
HashSet<string>? members = null;
|
||||
bool color = false;
|
||||
|
||||
for (int i = 0; i < tokens.Count; i++)
|
||||
@@ -68,17 +66,11 @@ namespace LuaScript.Compat
|
||||
tokens[i + 1].IsSymbol(".") &&
|
||||
tokens[i + 2].Kind == LuaTokenKind.Name)
|
||||
{
|
||||
string member = tokens[i + 2].Text;
|
||||
if (member.Length == 6 && member.StartsWith("check", StringComparison.Ordinal))
|
||||
{
|
||||
char digit = member[5];
|
||||
if (digit is >= '0' and <= '3')
|
||||
checks[digit - '0'] = true;
|
||||
}
|
||||
(members ??= new HashSet<string>(StringComparer.Ordinal)).Add(tokens[i + 2].Text);
|
||||
}
|
||||
}
|
||||
|
||||
return new ScriptParameterUsage(checks[0], checks[1], checks[2], checks[3], color);
|
||||
return new ScriptParameterUsage(members, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace LuaScript.Diagnostics
|
||||
{
|
||||
internal enum LuaScriptDiagnosticKind
|
||||
{
|
||||
Compile,
|
||||
Runtime,
|
||||
Timeout,
|
||||
}
|
||||
|
||||
internal readonly record struct LuaScriptDiagnostic(
|
||||
LuaScriptDiagnosticKind Kind,
|
||||
int Line,
|
||||
int Column,
|
||||
int Length,
|
||||
string Message);
|
||||
|
||||
internal static partial class LuaScriptDiagnosticParser
|
||||
{
|
||||
[GeneratedRegex(@"^LuaScript:\((\d+),(\d+)(?:-(\d+)(?:,(\d+))?)?\):\s*", RegexOptions.None)]
|
||||
private static partial Regex LocationPattern();
|
||||
|
||||
public static LuaScriptDiagnostic Parse(LuaScriptDiagnosticKind kind, string? message)
|
||||
{
|
||||
var text = message ?? string.Empty;
|
||||
var match = LocationPattern().Match(text);
|
||||
if (!match.Success)
|
||||
return new LuaScriptDiagnostic(kind, 0, 0, 0, text.Trim());
|
||||
|
||||
int line = int.Parse(match.Groups[1].Value);
|
||||
int columnStart = int.Parse(match.Groups[2].Value);
|
||||
|
||||
int length = 0;
|
||||
if (match.Groups[3].Success && !match.Groups[4].Success)
|
||||
length = Math.Max(0, int.Parse(match.Groups[3].Value) - columnStart);
|
||||
|
||||
return new LuaScriptDiagnostic(kind, line, columnStart + 1, length, text[match.Length..].Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using ICSharpCode.AvalonEdit.Document;
|
||||
using ICSharpCode.AvalonEdit.Folding;
|
||||
using ICSharpCode.AvalonEdit.Rendering;
|
||||
|
||||
namespace LuaScript.Diagnostics
|
||||
{
|
||||
internal sealed class LuaScriptDiagnosticOverlay : IBackgroundRenderer, ILuaScriptDiagnosticsListener
|
||||
{
|
||||
private static readonly FieldInfo? s_textViewsField = ResolveTextViewsField();
|
||||
|
||||
private static readonly Pen s_squigglePen = CreateSquigglePen();
|
||||
|
||||
private sealed class Marker : ISegment
|
||||
{
|
||||
public required int Offset { get; init; }
|
||||
public required int Length { get; init; }
|
||||
public int EndOffset => Offset + Length;
|
||||
public required LuaScriptDiagnostic Diagnostic { get; init; }
|
||||
}
|
||||
|
||||
private readonly TextView _textView;
|
||||
private readonly ToolTip _toolTip = new() { Placement = PlacementMode.Mouse };
|
||||
private readonly List<Marker> _markers = [];
|
||||
private object? _renderedText;
|
||||
private bool _isDirty = true;
|
||||
|
||||
public static void Attach(FoldingManager manager)
|
||||
{
|
||||
var textView = ResolveTextView(manager);
|
||||
if (textView is null)
|
||||
return;
|
||||
|
||||
foreach (var renderer in textView.BackgroundRenderers)
|
||||
{
|
||||
if (renderer is LuaScriptDiagnosticOverlay)
|
||||
return;
|
||||
}
|
||||
|
||||
_ = new LuaScriptDiagnosticOverlay(textView);
|
||||
}
|
||||
|
||||
private LuaScriptDiagnosticOverlay(TextView textView)
|
||||
{
|
||||
_textView = textView;
|
||||
textView.BackgroundRenderers.Add(this);
|
||||
textView.MouseHover += OnMouseHover;
|
||||
textView.MouseHoverStopped += OnMouseHoverStopped;
|
||||
LuaScriptDiagnostics.Instance.Subscribe(this);
|
||||
}
|
||||
|
||||
public KnownLayer Layer => KnownLayer.Selection;
|
||||
|
||||
public void OnDiagnosticsChanged()
|
||||
{
|
||||
_textView.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
_isDirty = true;
|
||||
_textView.InvalidateLayer(KnownLayer.Selection);
|
||||
});
|
||||
}
|
||||
|
||||
public void Draw(TextView textView, DrawingContext drawingContext)
|
||||
{
|
||||
var document = textView.Document;
|
||||
if (document is null)
|
||||
return;
|
||||
|
||||
if (_isDirty || !ReferenceEquals(document.Text, _renderedText))
|
||||
Rebuild(document);
|
||||
|
||||
if (_markers.Count == 0 || !textView.VisualLinesValid)
|
||||
return;
|
||||
|
||||
foreach (var marker in _markers)
|
||||
{
|
||||
foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker, false))
|
||||
DrawSquiggle(drawingContext, rect);
|
||||
}
|
||||
}
|
||||
|
||||
private void Rebuild(TextDocument document)
|
||||
{
|
||||
_isDirty = false;
|
||||
_renderedText = document.Text;
|
||||
_markers.Clear();
|
||||
|
||||
foreach (var diagnostic in LuaScriptDiagnostics.Instance.Get(document.Text))
|
||||
{
|
||||
if (TryCreateMarker(document, diagnostic, out var marker))
|
||||
_markers.Add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryCreateMarker(TextDocument document, LuaScriptDiagnostic diagnostic, out Marker marker)
|
||||
{
|
||||
marker = null!;
|
||||
|
||||
int lineNumber = diagnostic.Line > 0 ? diagnostic.Line : 1;
|
||||
if (lineNumber > document.LineCount)
|
||||
return false;
|
||||
|
||||
var line = document.GetLineByNumber(lineNumber);
|
||||
|
||||
int offset;
|
||||
int length;
|
||||
if (diagnostic.Line > 0 && diagnostic.Column > 0 && diagnostic.Length > 0)
|
||||
{
|
||||
offset = Math.Min(line.Offset + diagnostic.Column - 1, line.EndOffset);
|
||||
length = Math.Min(diagnostic.Length, line.EndOffset - offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = SkipLeadingWhitespace(document, line);
|
||||
length = line.EndOffset - offset;
|
||||
}
|
||||
|
||||
if (length <= 0)
|
||||
{
|
||||
if (line.Length == 0)
|
||||
return false;
|
||||
offset = line.Offset;
|
||||
length = line.Length;
|
||||
}
|
||||
|
||||
marker = new Marker { Offset = offset, Length = length, Diagnostic = diagnostic };
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int SkipLeadingWhitespace(TextDocument document, DocumentLine line)
|
||||
{
|
||||
int offset = line.Offset;
|
||||
while (offset < line.EndOffset)
|
||||
{
|
||||
char c = document.GetCharAt(offset);
|
||||
if (c != ' ' && c != '\t')
|
||||
break;
|
||||
offset++;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
private void OnMouseHover(object? sender, MouseEventArgs e)
|
||||
{
|
||||
var document = _textView.Document;
|
||||
if (document is null)
|
||||
return;
|
||||
|
||||
var position = _textView.GetPositionFloor(e.GetPosition(_textView) + _textView.ScrollOffset);
|
||||
if (position is null)
|
||||
return;
|
||||
|
||||
int offset = document.GetOffset(position.Value.Location);
|
||||
foreach (var marker in _markers)
|
||||
{
|
||||
if (offset < marker.Offset || offset > marker.EndOffset)
|
||||
continue;
|
||||
|
||||
_toolTip.Content = BuildToolTipContent(marker.Diagnostic);
|
||||
_toolTip.IsOpen = true;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseHoverStopped(object? sender, MouseEventArgs e)
|
||||
{
|
||||
_toolTip.IsOpen = false;
|
||||
}
|
||||
|
||||
private static object BuildToolTipContent(LuaScriptDiagnostic diagnostic)
|
||||
{
|
||||
var panel = new StackPanel { MaxWidth = 480 };
|
||||
panel.Children.Add(new TextBlock { Text = KindLabel(diagnostic.Kind), FontWeight = FontWeights.Bold });
|
||||
if (!string.IsNullOrEmpty(diagnostic.Message))
|
||||
panel.Children.Add(new TextBlock { Text = diagnostic.Message, TextWrapping = TextWrapping.Wrap });
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static string KindLabel(LuaScriptDiagnosticKind kind) => kind switch
|
||||
{
|
||||
LuaScriptDiagnosticKind.Compile => Texts.DiagnosticCompile,
|
||||
LuaScriptDiagnosticKind.Timeout => Texts.DiagnosticTimeout,
|
||||
_ => Texts.DiagnosticRuntime,
|
||||
};
|
||||
|
||||
private static void DrawSquiggle(DrawingContext drawingContext, Rect rect)
|
||||
{
|
||||
if (rect.Width <= 0)
|
||||
return;
|
||||
|
||||
const double step = 3.0;
|
||||
double baseline = rect.Bottom - 0.5;
|
||||
|
||||
var geometry = new StreamGeometry();
|
||||
using (var context = geometry.Open())
|
||||
{
|
||||
context.BeginFigure(new Point(rect.Left, baseline), false, false);
|
||||
|
||||
var points = new List<Point>();
|
||||
int index = 0;
|
||||
for (double x = rect.Left; x <= rect.Right; x += step)
|
||||
{
|
||||
points.Add(new Point(x, baseline - (index % 2 == 0 ? 0.0 : step)));
|
||||
index++;
|
||||
}
|
||||
context.PolyLineTo(points, true, false);
|
||||
}
|
||||
geometry.Freeze();
|
||||
|
||||
drawingContext.DrawGeometry(null, s_squigglePen, geometry);
|
||||
}
|
||||
|
||||
private static Pen CreateSquigglePen()
|
||||
{
|
||||
var pen = new Pen(new SolidColorBrush(Color.FromRgb(0xE5, 0x1A, 0x1A)), 1.0);
|
||||
pen.Brush.Freeze();
|
||||
pen.Freeze();
|
||||
return pen;
|
||||
}
|
||||
|
||||
private static FieldInfo? ResolveTextViewsField()
|
||||
{
|
||||
foreach (var field in typeof(FoldingManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
|
||||
{
|
||||
if (typeof(IEnumerable<TextView>).IsAssignableFrom(field.FieldType))
|
||||
return field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TextView? ResolveTextView(FoldingManager? manager)
|
||||
{
|
||||
if (manager is null || s_textViewsField is null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
if (s_textViewsField.GetValue(manager) is IEnumerable<TextView> views)
|
||||
{
|
||||
foreach (var view in views)
|
||||
{
|
||||
if (view is not null)
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LuaScript.Diagnostics
|
||||
{
|
||||
internal interface ILuaScriptDiagnosticsListener
|
||||
{
|
||||
void OnDiagnosticsChanged();
|
||||
}
|
||||
|
||||
internal sealed class LuaScriptDiagnostics
|
||||
{
|
||||
public static LuaScriptDiagnostics Instance { get; } = new();
|
||||
|
||||
private const int MaxTrackedScripts = 64;
|
||||
|
||||
private readonly object _gate = new();
|
||||
private readonly Dictionary<string, IReadOnlyList<LuaScriptDiagnostic>> _entries = new(StringComparer.Ordinal);
|
||||
private readonly Queue<string> _insertionOrder = new();
|
||||
private readonly List<WeakReference<ILuaScriptDiagnosticsListener>> _listeners = [];
|
||||
|
||||
private LuaScriptDiagnostics()
|
||||
{
|
||||
}
|
||||
|
||||
public void Subscribe(ILuaScriptDiagnosticsListener listener)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
PruneDeadListeners();
|
||||
_listeners.Add(new WeakReference<ILuaScriptDiagnosticsListener>(listener));
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<LuaScriptDiagnostic> Get(string? script)
|
||||
{
|
||||
if (script is null)
|
||||
return [];
|
||||
|
||||
lock (_gate)
|
||||
return _entries.TryGetValue(script, out var diagnostics) ? diagnostics : [];
|
||||
}
|
||||
|
||||
public void Report(string? script, IReadOnlyList<LuaScriptDiagnostic> diagnostics)
|
||||
{
|
||||
if (script is null)
|
||||
return;
|
||||
|
||||
diagnostics ??= [];
|
||||
|
||||
ILuaScriptDiagnosticsListener[] targets;
|
||||
lock (_gate)
|
||||
{
|
||||
if (_entries.TryGetValue(script, out var existing) && AreEqual(existing, diagnostics))
|
||||
return;
|
||||
|
||||
if (!_entries.ContainsKey(script))
|
||||
_insertionOrder.Enqueue(script);
|
||||
|
||||
_entries[script] = diagnostics;
|
||||
|
||||
while (_entries.Count > MaxTrackedScripts && _insertionOrder.Count > 0)
|
||||
{
|
||||
var oldest = _insertionOrder.Dequeue();
|
||||
if (!string.Equals(oldest, script, StringComparison.Ordinal))
|
||||
_entries.Remove(oldest);
|
||||
}
|
||||
|
||||
targets = CollectLiveListeners();
|
||||
}
|
||||
|
||||
foreach (var target in targets)
|
||||
target.OnDiagnosticsChanged();
|
||||
}
|
||||
|
||||
private ILuaScriptDiagnosticsListener[] CollectLiveListeners()
|
||||
{
|
||||
var live = new List<ILuaScriptDiagnosticsListener>(_listeners.Count);
|
||||
for (int i = _listeners.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_listeners[i].TryGetTarget(out var listener))
|
||||
live.Add(listener);
|
||||
else
|
||||
_listeners.RemoveAt(i);
|
||||
}
|
||||
return [.. live];
|
||||
}
|
||||
|
||||
private void PruneDeadListeners()
|
||||
{
|
||||
for (int i = _listeners.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!_listeners[i].TryGetTarget(out _))
|
||||
_listeners.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool AreEqual(IReadOnlyList<LuaScriptDiagnostic> a, IReadOnlyList<LuaScriptDiagnostic> b)
|
||||
{
|
||||
if (a.Count != b.Count)
|
||||
return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (!a[i].Equals(b[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ namespace LuaScript
|
||||
double Alpha,
|
||||
double Aspect,
|
||||
double[]? Poly = null,
|
||||
double Antialias = 1d);
|
||||
double Antialias = 1d,
|
||||
double Blend = 0d);
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using LuaScript.Compat;
|
||||
using Vortice.Direct2D1;
|
||||
using Vortice.Direct2D1.Effects;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Player;
|
||||
using Blend = YukkuriMovieMaker.Project.Blend;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
@@ -15,6 +18,8 @@ namespace LuaScript
|
||||
private ID2D1Bitmap1? _source;
|
||||
private ID2D1Bitmap1? _target;
|
||||
private AffineTransform2D? _placement;
|
||||
private Opacity? _opacityEffect;
|
||||
private ID2D1Image? _opacityOutput;
|
||||
private int _sourceWidth;
|
||||
private int _sourceHeight;
|
||||
private int _targetWidth;
|
||||
@@ -77,13 +82,14 @@ namespace LuaScript
|
||||
var interpolation = cmd.Antialias != 0d
|
||||
? BitmapInterpolationMode.Linear
|
||||
: BitmapInterpolationMode.NearestNeighbor;
|
||||
var blend = BlendModeMap.Resolve(cmd.Blend);
|
||||
|
||||
if (cmd.Poly is { } poly)
|
||||
{
|
||||
if (!DrawPolyMath.TrySolveAffine(poly, out var affine))
|
||||
continue;
|
||||
rt.Transform = affine * toTarget;
|
||||
rt.DrawBitmap(_source, (float)Math.Clamp(poly[20], 0d, 1d), interpolation);
|
||||
DrawSource(rt, (float)Math.Clamp(poly[20], 0d, 1d), interpolation, blend);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -98,7 +104,7 @@ namespace LuaScript
|
||||
Matrix3x2.CreateTranslation((float)(cmd.Ox - originX), (float)(cmd.Oy - originY));
|
||||
|
||||
rt.Transform = matrix;
|
||||
rt.DrawBitmap(_source, opacity, interpolation);
|
||||
DrawSource(rt, opacity, interpolation, blend);
|
||||
}
|
||||
rt.Transform = Matrix3x2.Identity;
|
||||
dc.EndDraw();
|
||||
@@ -108,6 +114,25 @@ namespace LuaScript
|
||||
return _placement.Output;
|
||||
}
|
||||
|
||||
private void DrawSource(ID2D1RenderTarget rt, float opacity, BitmapInterpolationMode interpolation, Blend blend)
|
||||
{
|
||||
if (blend == Blend.Normal)
|
||||
{
|
||||
rt.DrawBitmap(_source!, opacity, interpolation);
|
||||
return;
|
||||
}
|
||||
|
||||
var interp = ToImageInterpolation(interpolation);
|
||||
_opacityEffect!.Value = opacity;
|
||||
if (blend.IsCompositionEffect())
|
||||
_ctx.DeviceContext.DrawImage(_opacityOutput!, interpolationMode: interp, compositeMode: blend.ToD2DCompositionMode());
|
||||
else
|
||||
_ctx.DeviceContext.BlendImage(_opacityOutput!, blend.ToD2DBlendMode(), null, null, interp);
|
||||
}
|
||||
|
||||
private static InterpolationMode ToImageInterpolation(BitmapInterpolationMode mode) =>
|
||||
mode == BitmapInterpolationMode.Linear ? InterpolationMode.Linear : InterpolationMode.NearestNeighbor;
|
||||
|
||||
private void EnsureSource(int width, int height)
|
||||
{
|
||||
if (_source is not null && _sourceWidth == width && _sourceHeight == height)
|
||||
@@ -117,6 +142,13 @@ namespace LuaScript
|
||||
_source = _ctx.DeviceContext.CreateEmptyBitmap(width, height, BitmapOptions.Target);
|
||||
_sourceWidth = width;
|
||||
_sourceHeight = height;
|
||||
|
||||
if (_opacityEffect is null)
|
||||
{
|
||||
_opacityEffect = new Opacity(_ctx.DeviceContext);
|
||||
_opacityOutput = _opacityEffect.Output;
|
||||
}
|
||||
_opacityEffect.SetInput(0, _source, true);
|
||||
}
|
||||
|
||||
private void EnsureTarget(int width, int height)
|
||||
@@ -139,9 +171,13 @@ namespace LuaScript
|
||||
public void Dispose()
|
||||
{
|
||||
_placement?.Dispose();
|
||||
_opacityOutput?.Dispose();
|
||||
_opacityEffect?.Dispose();
|
||||
_source?.Dispose();
|
||||
_target?.Dispose();
|
||||
_placement = null;
|
||||
_opacityOutput = null;
|
||||
_opacityEffect = null;
|
||||
_source = null;
|
||||
_target = null;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ namespace LuaScript.Engine.Kernel
|
||||
Track1,
|
||||
Track2,
|
||||
Track3,
|
||||
Slider0,
|
||||
Slider1,
|
||||
Slider2,
|
||||
Slider3,
|
||||
Check0,
|
||||
Check1,
|
||||
Check2,
|
||||
@@ -105,6 +109,10 @@ namespace LuaScript.Engine.Kernel
|
||||
["track1"] = KernelUniform.Track1,
|
||||
["track2"] = KernelUniform.Track2,
|
||||
["track3"] = KernelUniform.Track3,
|
||||
["slider0"] = KernelUniform.Slider0,
|
||||
["slider1"] = KernelUniform.Slider1,
|
||||
["slider2"] = KernelUniform.Slider2,
|
||||
["slider3"] = KernelUniform.Slider3,
|
||||
["check0"] = KernelUniform.Check0,
|
||||
["check1"] = KernelUniform.Check1,
|
||||
["check2"] = KernelUniform.Check2,
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace LuaScript.Engine.Kernel
|
||||
values[(int)KernelUniform.Track1] = ctx.Track1;
|
||||
values[(int)KernelUniform.Track2] = ctx.Track2;
|
||||
values[(int)KernelUniform.Track3] = ctx.Track3;
|
||||
values[(int)KernelUniform.Slider0] = ctx.Slider0;
|
||||
values[(int)KernelUniform.Slider1] = ctx.Slider1;
|
||||
values[(int)KernelUniform.Slider2] = ctx.Slider2;
|
||||
values[(int)KernelUniform.Slider3] = ctx.Slider3;
|
||||
values[(int)KernelUniform.Check0] = ctx.Check0 ? 1d : 0d;
|
||||
values[(int)KernelUniform.Check1] = ctx.Check1 ? 1d : 0d;
|
||||
values[(int)KernelUniform.Check2] = ctx.Check2 ? 1d : 0d;
|
||||
|
||||
+117
-21
@@ -21,13 +21,18 @@ namespace LuaScript.Engine
|
||||
private Process? _process;
|
||||
private int _width;
|
||||
private int _height;
|
||||
private int _stringParamsCapacity = NativeProtocol.MinStringParamsCapacity;
|
||||
private long _pixelOffset = NativeProtocol.PixelOffset(NativeProtocol.MinStringParamsCapacity);
|
||||
private bool _alive;
|
||||
|
||||
private readonly byte[] _callbackTag = new byte[NativeProtocol.CallbackTagMax];
|
||||
private readonly byte[] _lastCallbackTag = new byte[NativeProtocol.CallbackTagMax];
|
||||
private readonly double[] _anchorBuffer = new double[Anchor.AnchorSupport.MaxAnchors * 3];
|
||||
private int _lastCallbackTagLength = -1;
|
||||
private string _lastCallbackTagText = string.Empty;
|
||||
private byte[]? _resultBuffer;
|
||||
private readonly Dictionary<string, byte[]> _stringNameBytes = new(StringComparer.Ordinal);
|
||||
private byte[] _stringValueBytes = new byte[256];
|
||||
|
||||
public LuaJitWorker(string nativeDir)
|
||||
{
|
||||
@@ -43,6 +48,7 @@ namespace LuaScript.Engine
|
||||
public bool Execute(
|
||||
string script,
|
||||
double[] fields,
|
||||
IReadOnlyDictionary<string, string> stringParameters,
|
||||
byte[] pixels,
|
||||
int width,
|
||||
int height,
|
||||
@@ -54,6 +60,7 @@ namespace LuaScript.Engine
|
||||
Func<string, double, (byte[] buffer, int w, int h)> loadMovie,
|
||||
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
|
||||
Action<DrawCommand> addDraw,
|
||||
Action<string, int, bool, int, double[]> setAnchor,
|
||||
out bool pixelsDirty,
|
||||
out bool bufferReplaced,
|
||||
out byte[]? newPixels,
|
||||
@@ -75,15 +82,17 @@ namespace LuaScript.Engine
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureWorker(width, height);
|
||||
int stringCapacity = ResolveStringCapacity(_stringParamsCapacity, MeasureStringParameters(stringParameters));
|
||||
EnsureWorker(width, height, stringCapacity);
|
||||
var view = _view!;
|
||||
|
||||
view.WriteArray(NativeProtocol.FieldsOffset, fields, 0, NativeProtocol.FieldCount);
|
||||
WriteStringParameters(view, stringParameters);
|
||||
view.Write(NativeProtocol.OffWidth, width);
|
||||
view.Write(NativeProtocol.OffHeight, height);
|
||||
view.Write(NativeProtocol.OffScriptLen, scriptBytes.Length);
|
||||
view.WriteArray(NativeProtocol.ScriptOffset, scriptBytes, 0, scriptBytes.Length);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, pixels, 0, pixels.Length);
|
||||
view.WriteArray(_pixelOffset, pixels, 0, pixels.Length);
|
||||
view.Write(NativeProtocol.OffPixelsDirty, 0);
|
||||
view.Write(NativeProtocol.OffErrorLen, 0);
|
||||
view.Write(NativeProtocol.OffStatus, NativeProtocol.StatusIdle);
|
||||
@@ -107,7 +116,7 @@ namespace LuaScript.Engine
|
||||
if (status != NativeProtocol.StatusCallback)
|
||||
break;
|
||||
|
||||
DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw);
|
||||
DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw, setAnchor);
|
||||
_workEvent.Set();
|
||||
}
|
||||
|
||||
@@ -123,6 +132,8 @@ namespace LuaScript.Engine
|
||||
for (int i = NativeProtocol.FirstWritableField; i <= NativeProtocol.LastWritableField; i++)
|
||||
fields[i] = view.ReadDouble(NativeProtocol.FieldsOffset + i * 8);
|
||||
|
||||
fields[NativeProtocol.DrawState] = view.ReadDouble(NativeProtocol.FieldsOffset + NativeProtocol.DrawState * 8);
|
||||
|
||||
resultWidth = view.ReadInt32(NativeProtocol.OffWidth);
|
||||
resultHeight = view.ReadInt32(NativeProtocol.OffHeight);
|
||||
bufferReplaced = resultWidth != width || resultHeight != height;
|
||||
@@ -135,18 +146,73 @@ namespace LuaScript.Engine
|
||||
int pixelSize = resultWidth * resultHeight * 4;
|
||||
if (_resultBuffer == null || _resultBuffer.Length < pixelSize)
|
||||
_resultBuffer = new byte[pixelSize];
|
||||
view.ReadArray(NativeProtocol.PixelOffset, _resultBuffer, 0, pixelSize);
|
||||
view.ReadArray(_pixelOffset, _resultBuffer, 0, pixelSize);
|
||||
newPixels = _resultBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
view.ReadArray(NativeProtocol.PixelOffset, pixels, 0, pixels.Length);
|
||||
view.ReadArray(_pixelOffset, pixels, 0, pixels.Length);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int MeasureStringParameters(IReadOnlyDictionary<string, string> stringParameters)
|
||||
{
|
||||
int total = 4;
|
||||
foreach (var pair in stringParameters)
|
||||
total += 8 + Encoding.UTF8.GetByteCount(pair.Key) + Encoding.UTF8.GetByteCount(pair.Value ?? string.Empty);
|
||||
return total;
|
||||
}
|
||||
|
||||
private static int ResolveStringCapacity(int current, int required)
|
||||
{
|
||||
int capacity = current;
|
||||
while (capacity < required)
|
||||
{
|
||||
if (capacity > int.MaxValue / 2)
|
||||
{
|
||||
capacity = required;
|
||||
break;
|
||||
}
|
||||
capacity *= 2;
|
||||
}
|
||||
while (capacity > NativeProtocol.MinStringParamsCapacity && required <= capacity / 2)
|
||||
capacity /= 2;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
private void WriteStringParameters(MemoryMappedViewAccessor view, IReadOnlyDictionary<string, string> stringParameters)
|
||||
{
|
||||
long basePos = NativeProtocol.StringParamsOffset;
|
||||
long limit = basePos + _stringParamsCapacity;
|
||||
long pos = basePos + 4;
|
||||
int count = 0;
|
||||
foreach (var pair in stringParameters)
|
||||
{
|
||||
if (!_stringNameBytes.TryGetValue(pair.Key, out var name))
|
||||
{
|
||||
name = Encoding.UTF8.GetBytes(pair.Key);
|
||||
_stringNameBytes[pair.Key] = name;
|
||||
}
|
||||
string value = pair.Value ?? string.Empty;
|
||||
int maxValueBytes = Encoding.UTF8.GetMaxByteCount(value.Length);
|
||||
if (_stringValueBytes.Length < maxValueBytes)
|
||||
_stringValueBytes = new byte[Math.Max(maxValueBytes, _stringValueBytes.Length * 2)];
|
||||
int valueLen = Encoding.UTF8.GetBytes(value, 0, value.Length, _stringValueBytes, 0);
|
||||
if (pos + 8 + name.Length + valueLen > limit)
|
||||
break;
|
||||
view.Write(pos, name.Length); pos += 4;
|
||||
view.WriteArray(pos, name, 0, name.Length); pos += name.Length;
|
||||
view.Write(pos, valueLen); pos += 4;
|
||||
view.WriteArray(pos, _stringValueBytes, 0, valueLen); pos += valueLen;
|
||||
count++;
|
||||
}
|
||||
view.Write(basePos, count);
|
||||
view.Write(NativeProtocol.OffStringParamsLen, (int)(pos - basePos));
|
||||
}
|
||||
|
||||
private void DispatchCallback(
|
||||
MemoryMappedViewAccessor view,
|
||||
Func<string, int, SceneObjectInfo?> resolveObject,
|
||||
@@ -155,7 +221,8 @@ namespace LuaScript.Engine
|
||||
Func<string, (byte[] buffer, int w, int h)> loadImage,
|
||||
Func<string, double, (byte[] buffer, int w, int h)> loadMovie,
|
||||
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
|
||||
Action<DrawCommand> addDraw)
|
||||
Action<DrawCommand> addDraw,
|
||||
Action<string, int, bool, int, double[]> setAnchor)
|
||||
{
|
||||
int kind = view.ReadInt32(NativeProtocol.OffCallbackKind);
|
||||
switch (kind)
|
||||
@@ -184,9 +251,33 @@ namespace LuaScript.Engine
|
||||
case NativeProtocol.CbKindDrawPoly:
|
||||
ResolveDrawPolyCallback(view, addDraw);
|
||||
break;
|
||||
case NativeProtocol.CbKindSetAnchor:
|
||||
ResolveSetAnchorCallback(view, setAnchor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResolveSetAnchorCallback(MemoryMappedViewAccessor view, Action<string, int, bool, int, double[]> setAnchor)
|
||||
{
|
||||
int tagLen = Math.Clamp(view.ReadInt32(NativeProtocol.OffCallbackTagLen), 0, NativeProtocol.CallbackTagMax);
|
||||
view.ReadArray(NativeProtocol.CallbackTagOffset, _callbackTag, 0, tagLen);
|
||||
string group = Encoding.UTF8.GetString(_callbackTag, 0, tagLen);
|
||||
|
||||
long rOff = NativeProtocol.CallbackResultOffset;
|
||||
int count = Math.Clamp((int)view.ReadDouble(rOff + 0 * 8), 0, Anchor.AnchorSupport.MaxAnchors);
|
||||
bool is3D = view.ReadDouble(rOff + 1 * 8) != 0d;
|
||||
int connection = (int)view.ReadDouble(rOff + 2 * 8);
|
||||
|
||||
Array.Clear(_anchorBuffer, 0, _anchorBuffer.Length);
|
||||
try { setAnchor(group, count, is3D, connection, _anchorBuffer); }
|
||||
catch { }
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
for (int i = 0; i < count * stride; i++)
|
||||
view.Write(NativeProtocol.CallbackTagOffset + i * 8, _anchorBuffer[i]);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
private static void ResolveDrawCallback(MemoryMappedViewAccessor view, Action<DrawCommand> addDraw)
|
||||
{
|
||||
long rOff = NativeProtocol.CallbackResultOffset;
|
||||
@@ -197,8 +288,9 @@ namespace LuaScript.Engine
|
||||
double alpha = view.ReadDouble(rOff + 4 * 8);
|
||||
double aspect = view.ReadDouble(rOff + 5 * 8);
|
||||
double antialias = view.ReadDouble(rOff + 6 * 8);
|
||||
double blend = view.ReadDouble(rOff + 7 * 8);
|
||||
|
||||
try { addDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, antialias)); }
|
||||
try { addDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, antialias, blend)); }
|
||||
catch { }
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
@@ -209,8 +301,9 @@ namespace LuaScript.Engine
|
||||
for (int i = 0; i < DrawPolyMath.Length; i++)
|
||||
poly[i] = view.ReadDouble(NativeProtocol.CallbackTagOffset + i * 8);
|
||||
double antialias = view.ReadDouble(NativeProtocol.CallbackTagOffset + DrawPolyMath.Length * 8);
|
||||
double blend = view.ReadDouble(NativeProtocol.CallbackTagOffset + (DrawPolyMath.Length + 1) * 8);
|
||||
|
||||
try { addDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, antialias)); }
|
||||
try { addDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, antialias, blend)); }
|
||||
catch { }
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
@@ -264,7 +357,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -273,7 +366,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
view.WriteArray(_pixelOffset, result.buffer, 0, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -299,7 +392,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -308,7 +401,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
view.WriteArray(_pixelOffset, result.buffer, 0, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -325,7 +418,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -334,7 +427,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
view.WriteArray(_pixelOffset, result.buffer, 0, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -352,7 +445,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -361,7 +454,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
view.WriteArray(_pixelOffset, result.buffer, 0, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -409,20 +502,22 @@ namespace LuaScript.Engine
|
||||
return _lastCallbackTagText;
|
||||
}
|
||||
|
||||
private void EnsureWorker(int width, int height)
|
||||
private void EnsureWorker(int width, int height, int stringCapacity)
|
||||
{
|
||||
if (_alive && _process is { HasExited: false } && _width == width && _height == height)
|
||||
if (_alive && _process is { HasExited: false } && _width == width && _height == height && _stringParamsCapacity == stringCapacity)
|
||||
return;
|
||||
|
||||
KillWorker();
|
||||
StartWorker(width, height);
|
||||
StartWorker(width, height, stringCapacity);
|
||||
}
|
||||
|
||||
private void StartWorker(int width, int height)
|
||||
private void StartWorker(int width, int height, int stringCapacity)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
long size = NativeProtocol.BufferSize(width, height);
|
||||
_stringParamsCapacity = stringCapacity;
|
||||
_pixelOffset = NativeProtocol.PixelOffset(stringCapacity);
|
||||
long size = NativeProtocol.BufferSize(width, height, stringCapacity);
|
||||
|
||||
string suffix = Guid.NewGuid().ToString("N");
|
||||
string mapName = "LuaScriptMap_" + suffix;
|
||||
@@ -449,6 +544,7 @@ namespace LuaScript.Engine
|
||||
psi.ArgumentList.Add(workName);
|
||||
psi.ArgumentList.Add(doneName);
|
||||
psi.ArgumentList.Add(_shimScript);
|
||||
psi.ArgumentList.Add(stringCapacity.ToString());
|
||||
|
||||
_process = Process.Start(psi);
|
||||
if (_process is not null)
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace LuaScript.Engine
|
||||
{
|
||||
internal static class NativeFieldMap
|
||||
{
|
||||
private const double Epsilon = 1e-10;
|
||||
|
||||
public static void ToFields(AviUtlScriptContext ctx, double[] f)
|
||||
{
|
||||
f[NativeProtocol.W] = ctx.ImageWidth;
|
||||
@@ -38,6 +36,10 @@ namespace LuaScript.Engine
|
||||
f[NativeProtocol.Track1] = ctx.Track1;
|
||||
f[NativeProtocol.Track2] = ctx.Track2;
|
||||
f[NativeProtocol.Track3] = ctx.Track3;
|
||||
f[NativeProtocol.Slider0] = ctx.Slider0;
|
||||
f[NativeProtocol.Slider1] = ctx.Slider1;
|
||||
f[NativeProtocol.Slider2] = ctx.Slider2;
|
||||
f[NativeProtocol.Slider3] = ctx.Slider3;
|
||||
f[NativeProtocol.Check0] = ctx.Check0 ? 1d : 0d;
|
||||
f[NativeProtocol.Check1] = ctx.Check1 ? 1d : 0d;
|
||||
f[NativeProtocol.Check2] = ctx.Check2 ? 1d : 0d;
|
||||
@@ -89,6 +91,13 @@ namespace LuaScript.Engine
|
||||
f[NativeProtocol.Rxr],
|
||||
f[NativeProtocol.Ryr],
|
||||
f[NativeProtocol.Rzr]);
|
||||
|
||||
ctx.DrawStateOverride = f[NativeProtocol.DrawState] switch
|
||||
{
|
||||
1d => true,
|
||||
2d => false,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace LuaScript.Engine
|
||||
public const int OffCallbackKind = 44;
|
||||
public const int OffLoadResultWidth = 48;
|
||||
public const int OffLoadResultHeight = 52;
|
||||
public const int OffStringParamsLen = 56;
|
||||
|
||||
public const int HeaderSize = 64;
|
||||
|
||||
@@ -43,6 +44,9 @@ namespace LuaScript.Engine
|
||||
public const int CallbackResultOffset = CallbackTagOffset + CallbackTagMax;
|
||||
public const int CallbackResultCount = 8;
|
||||
|
||||
public const int StringParamsOffset = CallbackResultOffset + CallbackResultCount * 8;
|
||||
public const int MinStringParamsCapacity = 64 * 1024;
|
||||
|
||||
public const int CbKindGetObject = 0;
|
||||
public const int CbKindLoadFigure = 1;
|
||||
public const int CbKindEffect = 2;
|
||||
@@ -51,6 +55,7 @@ namespace LuaScript.Engine
|
||||
public const int CbKindLoadText = 5;
|
||||
public const int CbKindLoadImage = 6;
|
||||
public const int CbKindLoadMovie = 7;
|
||||
public const int CbKindSetAnchor = 8;
|
||||
|
||||
public const int CbExist = 0;
|
||||
public const int CbX = 1;
|
||||
@@ -61,7 +66,7 @@ namespace LuaScript.Engine
|
||||
public const int CbAlpha = 6;
|
||||
public const int CbLayer = 7;
|
||||
|
||||
public const int PixelOffset = CallbackResultOffset + CallbackResultCount * 8;
|
||||
public static int PixelOffset(int stringCapacity) => StringParamsOffset + stringCapacity;
|
||||
|
||||
public const int W = 0;
|
||||
public const int H = 1;
|
||||
@@ -121,13 +126,18 @@ namespace LuaScript.Engine
|
||||
public const int Check2 = 55;
|
||||
public const int Check3 = 56;
|
||||
public const int Color = 57;
|
||||
public const int Slider0 = 58;
|
||||
public const int Slider1 = 59;
|
||||
public const int Slider2 = 60;
|
||||
public const int Slider3 = 61;
|
||||
public const int DrawState = 62;
|
||||
|
||||
public const int FirstWritableField = X;
|
||||
public const int LastWritableField = Rzr;
|
||||
|
||||
public const int MaxPixelBufferSize = 3840 * 2160 * 4;
|
||||
|
||||
public static long BufferSize(int width, int height) =>
|
||||
PixelOffset + Math.Max((long)width * height * 4, MaxPixelBufferSize);
|
||||
public static long BufferSize(int width, int height, int stringCapacity) =>
|
||||
PixelOffset(stringCapacity) + Math.Max((long)width * height * 4, MaxPixelBufferSize);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ namespace LuaScript.Engine
|
||||
|
||||
public static bool UsesDrawingApi(string? script) =>
|
||||
script is not null &&
|
||||
script.Contains("obj.setoption", StringComparison.Ordinal);
|
||||
(script.Contains("obj.setoption", StringComparison.Ordinal) ||
|
||||
script.Contains("obj.setanchor", StringComparison.Ordinal));
|
||||
|
||||
private static bool TryGetDirective(string? script, out ScriptEngineKind kind)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,11 @@ namespace LuaScript
|
||||
"obj.rx", "obj.ry", "obj.rz",
|
||||
"obj.rxr", "obj.ryr", "obj.rzr",
|
||||
"obj.track0", "obj.track1", "obj.track2", "obj.track3",
|
||||
"obj.slider0", "obj.slider1", "obj.slider2", "obj.slider3",
|
||||
"obj.check0", "obj.check1", "obj.check2", "obj.check3",
|
||||
"obj.text", "obj.font", "obj.dir",
|
||||
"obj.file_video", "obj.file_audio", "obj.file_image", "obj.file_project",
|
||||
"obj.file_mp4", "obj.file_exo", "obj.file_subtitle", "obj.file_shader",
|
||||
"obj.time", "obj.totaltime", "obj.t", "obj.frame", "obj.totalframe",
|
||||
"obj.framerate", "obj.layer", "obj.index", "obj.num",
|
||||
"obj.getpixel", "obj.setpixel",
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using ICSharpCode.AvalonEdit.Document;
|
||||
using ICSharpCode.AvalonEdit.Folding;
|
||||
using LuaScript.Diagnostics;
|
||||
using YukkuriMovieMaker.Controls.AvalonEdit.FoldingStrategy;
|
||||
|
||||
namespace LuaScript
|
||||
@@ -25,6 +26,7 @@ namespace LuaScript
|
||||
public void UpdateFoldings(FoldingManager manager, TextDocument document)
|
||||
{
|
||||
manager.UpdateFoldings(CreateNewFoldings(document, out int firstErrorOffset), firstErrorOffset);
|
||||
LuaScriptDiagnosticOverlay.Attach(manager);
|
||||
}
|
||||
|
||||
private static IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>1.9.1</Version>
|
||||
<Version>1.11.0</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -94,6 +94,10 @@
|
||||
<AdditionalFiles Include="**/*.csv" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Compat\AviUtlCompatMap.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Windows.Media;
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using Newtonsoft.Json;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
@@ -10,6 +13,7 @@ using YukkuriMovieMaker.ItemEditor.CustomVisibilityAttributes;
|
||||
using YukkuriMovieMaker.Player.Video;
|
||||
using YukkuriMovieMaker.Plugin;
|
||||
using YukkuriMovieMaker.Plugin.Effects;
|
||||
using YukkuriMovieMaker.Settings;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
@@ -62,6 +66,34 @@ namespace LuaScript
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack3Visible), true)]
|
||||
public Animation Track3 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider0), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 1, 10)]
|
||||
[DefaultValue(1)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider0Visible), true)]
|
||||
public int Slider0 { get => _slider0; set => Set(ref _slider0, value); }
|
||||
int _slider0 = 1;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider1), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 0, 100)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider1Visible), true)]
|
||||
public int Slider1 { get => _slider1; set => Set(ref _slider1, value); }
|
||||
int _slider1;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider2), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 0, 1000)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider2Visible), true)]
|
||||
public int Slider2 { get => _slider2; set => Set(ref _slider2, value); }
|
||||
int _slider2;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider3), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", -1000, 1000)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider3Visible), true)]
|
||||
public int Slider3 { get => _slider3; set => Set(ref _slider3, value); }
|
||||
int _slider3;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check0), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck0Visible), true)]
|
||||
@@ -92,6 +124,76 @@ namespace LuaScript
|
||||
public Color Color { get => _color; set => Set(ref _color, value); }
|
||||
Color _color = Colors.White;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Text), Description = nameof(Texts.TextDesc), ResourceType = typeof(Texts))]
|
||||
[TextEditor(AcceptsReturn = true, PropertyEditorSize = PropertyEditorSize.FullWidth)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTextVisible), true)]
|
||||
public string Text { get => _text; set => Set(ref _text, value); }
|
||||
string _text = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Font), Description = nameof(Texts.FontDesc), ResourceType = typeof(Texts))]
|
||||
[FontComboBox]
|
||||
[ShowPropertyEditorWhen(nameof(IsFontVisible), true)]
|
||||
public string Font { get => _font; set => Set(ref _font, value); }
|
||||
string _font = "メイリオ";
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Directory), Description = nameof(Texts.DirectoryDesc), ResourceType = typeof(Texts))]
|
||||
[DirectorySelector(PropertyEditorSize = PropertyEditorSize.FullWidth)]
|
||||
[ShowPropertyEditorWhen(nameof(IsDirectoryVisible), true)]
|
||||
public string Directory { get => _directory; set => Set(ref _directory, value); }
|
||||
string _directory = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileVideo), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.VideoItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileVideoVisible), true)]
|
||||
public string FileVideo { get => _fileVideo; set => Set(ref _fileVideo, value); }
|
||||
string _fileVideo = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileAudio), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.AudioItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileAudioVisible), true)]
|
||||
public string FileAudio { get => _fileAudio; set => Set(ref _fileAudio, value); }
|
||||
string _fileAudio = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileImage), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.ImageItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileImageVisible), true)]
|
||||
public string FileImage { get => _fileImage; set => Set(ref _fileImage, value); }
|
||||
string _fileImage = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileProject), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Project)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileProjectVisible), true)]
|
||||
public string FileProject { get => _fileProject; set => Set(ref _fileProject, value); }
|
||||
string _fileProject = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileMp4), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.MP4)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileMp4Visible), true)]
|
||||
public string FileMp4 { get => _fileMp4; set => Set(ref _fileMp4, value); }
|
||||
string _fileMp4 = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileExo), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Exo)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileExoVisible), true)]
|
||||
public string FileExo { get => _fileExo; set => Set(ref _fileExo, value); }
|
||||
string _fileExo = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileSubtitle), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Subtitle)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileSubtitleVisible), true)]
|
||||
public string FileSubtitle { get => _fileSubtitle; set => Set(ref _fileSubtitle, value); }
|
||||
string _fileSubtitle = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileShader), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.PixelShaderSource)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileShaderVisible), true)]
|
||||
public string FileShader { get => _fileShader; set => Set(ref _fileShader, value); }
|
||||
string _fileShader = string.Empty;
|
||||
|
||||
[JsonIgnore] public bool IsSlider0Visible { get => _isSlider0Visible; private set => Set(ref _isSlider0Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider1Visible { get => _isSlider1Visible; private set => Set(ref _isSlider1Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider2Visible { get => _isSlider2Visible; private set => Set(ref _isSlider2Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider3Visible { get => _isSlider3Visible; private set => Set(ref _isSlider3Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack0Visible { get => _isTrack0Visible; private set => Set(ref _isTrack0Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack1Visible { get => _isTrack1Visible; private set => Set(ref _isTrack1Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack2Visible { get => _isTrack2Visible; private set => Set(ref _isTrack2Visible, value); }
|
||||
@@ -101,7 +203,22 @@ namespace LuaScript
|
||||
[JsonIgnore] public bool IsCheck2Visible { get => _isCheck2Visible; private set => Set(ref _isCheck2Visible, value); }
|
||||
[JsonIgnore] public bool IsCheck3Visible { get => _isCheck3Visible; private set => Set(ref _isCheck3Visible, value); }
|
||||
[JsonIgnore] public bool IsColorVisible { get => _isColorVisible; private set => Set(ref _isColorVisible, value); }
|
||||
[JsonIgnore] public bool IsTextVisible { get => _isTextVisible; private set => Set(ref _isTextVisible, value); }
|
||||
[JsonIgnore] public bool IsFontVisible { get => _isFontVisible; private set => Set(ref _isFontVisible, value); }
|
||||
[JsonIgnore] public bool IsDirectoryVisible { get => _isDirectoryVisible; private set => Set(ref _isDirectoryVisible, value); }
|
||||
[JsonIgnore] public bool IsFileVideoVisible { get => _isFileVideoVisible; private set => Set(ref _isFileVideoVisible, value); }
|
||||
[JsonIgnore] public bool IsFileAudioVisible { get => _isFileAudioVisible; private set => Set(ref _isFileAudioVisible, value); }
|
||||
[JsonIgnore] public bool IsFileImageVisible { get => _isFileImageVisible; private set => Set(ref _isFileImageVisible, value); }
|
||||
[JsonIgnore] public bool IsFileProjectVisible { get => _isFileProjectVisible; private set => Set(ref _isFileProjectVisible, value); }
|
||||
[JsonIgnore] public bool IsFileMp4Visible { get => _isFileMp4Visible; private set => Set(ref _isFileMp4Visible, value); }
|
||||
[JsonIgnore] public bool IsFileExoVisible { get => _isFileExoVisible; private set => Set(ref _isFileExoVisible, value); }
|
||||
[JsonIgnore] public bool IsFileSubtitleVisible { get => _isFileSubtitleVisible; private set => Set(ref _isFileSubtitleVisible, value); }
|
||||
[JsonIgnore] public bool IsFileShaderVisible { get => _isFileShaderVisible; private set => Set(ref _isFileShaderVisible, value); }
|
||||
|
||||
bool _isSlider0Visible;
|
||||
bool _isSlider1Visible;
|
||||
bool _isSlider2Visible;
|
||||
bool _isSlider3Visible;
|
||||
bool _isTrack0Visible = true;
|
||||
bool _isTrack1Visible = true;
|
||||
bool _isTrack2Visible = true;
|
||||
@@ -111,6 +228,17 @@ namespace LuaScript
|
||||
bool _isCheck2Visible;
|
||||
bool _isCheck3Visible;
|
||||
bool _isColorVisible;
|
||||
bool _isTextVisible;
|
||||
bool _isFontVisible;
|
||||
bool _isDirectoryVisible;
|
||||
bool _isFileVideoVisible;
|
||||
bool _isFileAudioVisible;
|
||||
bool _isFileImageVisible;
|
||||
bool _isFileProjectVisible;
|
||||
bool _isFileMp4Visible;
|
||||
bool _isFileExoVisible;
|
||||
bool _isFileSubtitleVisible;
|
||||
bool _isFileShaderVisible;
|
||||
|
||||
private void UpdateLayout()
|
||||
{
|
||||
@@ -120,6 +248,10 @@ namespace LuaScript
|
||||
bool hasAny = layout.HasAny;
|
||||
var usage = ScriptParameterUsage.Detect(_script);
|
||||
|
||||
IsSlider0Visible = usage.Slider(0);
|
||||
IsSlider1Visible = usage.Slider(1);
|
||||
IsSlider2Visible = usage.Slider(2);
|
||||
IsSlider3Visible = usage.Slider(3);
|
||||
IsTrack0Visible = !hasAny || layout.HasTrack(0);
|
||||
IsTrack1Visible = !hasAny || layout.HasTrack(1);
|
||||
IsTrack2Visible = !hasAny || layout.HasTrack(2);
|
||||
@@ -129,6 +261,17 @@ namespace LuaScript
|
||||
IsCheck2Visible = layout.HasCheck(2) || (!hasAny && usage.Check2);
|
||||
IsCheck3Visible = layout.HasCheck(3) || (!hasAny && usage.Check3);
|
||||
IsColorVisible = layout.HasColor || (!hasAny && usage.Color);
|
||||
IsTextVisible = usage.Uses("text");
|
||||
IsFontVisible = usage.Uses("font");
|
||||
IsDirectoryVisible = usage.Uses("dir");
|
||||
IsFileVideoVisible = usage.Uses("file_video");
|
||||
IsFileAudioVisible = usage.Uses("file_audio");
|
||||
IsFileImageVisible = usage.Uses("file_image");
|
||||
IsFileProjectVisible = usage.Uses("file_project");
|
||||
IsFileMp4Visible = usage.Uses("file_mp4");
|
||||
IsFileExoVisible = usage.Uses("file_exo");
|
||||
IsFileSubtitleVisible = usage.Uses("file_subtitle");
|
||||
IsFileShaderVisible = usage.Uses("file_shader");
|
||||
|
||||
SeedDefaults(layout);
|
||||
}
|
||||
@@ -152,6 +295,19 @@ namespace LuaScript
|
||||
return Color.FromRgb(r, g, b);
|
||||
}
|
||||
|
||||
public ImmutableList<LuaAnchorPoint> Anchors
|
||||
{
|
||||
get => _anchors;
|
||||
set { if (Set(ref _anchors, value ?? ImmutableList<LuaAnchorPoint>.Empty)) AnchorVersion++; }
|
||||
}
|
||||
ImmutableList<LuaAnchorPoint> _anchors = ImmutableList<LuaAnchorPoint>.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
internal int AnchorVersion { get; private set; }
|
||||
|
||||
internal void ApplyAnchorDrag(string group, int index, double dx, double dy, double dz)
|
||||
=> Anchors = AnchorSupport.ApplyDrag(Anchors, group, index, dx, dy, dz);
|
||||
|
||||
public override IEnumerable<string> CreateExoVideoFilters(int keyFrameIndex, ExoOutputDescription exoOutputDescription) => [];
|
||||
|
||||
public override IVideoEffectProcessor CreateVideoEffect(IGraphicsDevicesAndContext devices)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using LuaScript.Diagnostics;
|
||||
using LuaScript.Engine;
|
||||
using LuaScript.Engine.Kernel;
|
||||
using Vortice;
|
||||
@@ -29,6 +32,10 @@ namespace LuaScript
|
||||
double Track1,
|
||||
double Track2,
|
||||
double Track3,
|
||||
double Slider0,
|
||||
double Slider1,
|
||||
double Slider2,
|
||||
double Slider3,
|
||||
bool Check0,
|
||||
bool Check1,
|
||||
bool Check2,
|
||||
@@ -36,6 +43,7 @@ namespace LuaScript
|
||||
bool HasColor,
|
||||
int Color,
|
||||
string Script,
|
||||
int StringsVersion,
|
||||
TimelineSourceUsage Usage,
|
||||
Guid SceneId,
|
||||
int TimelineFrame,
|
||||
@@ -49,6 +57,7 @@ namespace LuaScript
|
||||
int GroupCount,
|
||||
int TimelineTotalFrame,
|
||||
double TimelineTotalTime,
|
||||
int AnchorVersion,
|
||||
DrawDescription InputDesc
|
||||
);
|
||||
|
||||
@@ -90,6 +99,7 @@ namespace LuaScript
|
||||
private bool _isFirst = true;
|
||||
private string _sourceScript = string.Empty;
|
||||
private string _runnableScript = string.Empty;
|
||||
private int[] _runnableLineMap = [];
|
||||
private bool _runnableCached;
|
||||
private ID2D1Image? _cachedInput;
|
||||
private RenderKey _cachedKey;
|
||||
@@ -138,12 +148,39 @@ namespace LuaScript
|
||||
if (_runnableCached && string.Equals(source, _sourceScript, StringComparison.Ordinal))
|
||||
return _runnableScript;
|
||||
|
||||
_runnableScript = AviUtlScript.Transform(source);
|
||||
var (code, lineMap) = AviUtlScript.TransformWithMap(source);
|
||||
_runnableScript = code;
|
||||
_runnableLineMap = lineMap;
|
||||
_sourceScript = source;
|
||||
_runnableCached = true;
|
||||
return _runnableScript;
|
||||
}
|
||||
|
||||
private static LuaScriptDiagnosticKind ClassifyDiagnostic(LuaScriptException exception) => exception switch
|
||||
{
|
||||
LuaScriptCompilationException => LuaScriptDiagnosticKind.Compile,
|
||||
LuaScriptTimeoutException => LuaScriptDiagnosticKind.Timeout,
|
||||
_ => LuaScriptDiagnosticKind.Runtime,
|
||||
};
|
||||
|
||||
private LuaScriptDiagnostic CreateDiagnostic(LuaScriptDiagnosticKind kind, string message)
|
||||
{
|
||||
var diagnostic = LuaScriptDiagnosticParser.Parse(kind, message);
|
||||
return diagnostic.Line > 0
|
||||
? diagnostic with { Line = MapRunnableLine(diagnostic.Line) }
|
||||
: diagnostic;
|
||||
}
|
||||
|
||||
private int MapRunnableLine(int runnableLine)
|
||||
{
|
||||
int index = runnableLine - 1;
|
||||
if (index < 0 || index >= _runnableLineMap.Length)
|
||||
return runnableLine;
|
||||
|
||||
int sourceLine = _runnableLineMap[index];
|
||||
return sourceLine >= 0 ? sourceLine + 1 : 0;
|
||||
}
|
||||
|
||||
protected override void setInput(ID2D1Image? input)
|
||||
{
|
||||
if (!ReferenceEquals(_cachedInput, input))
|
||||
@@ -174,6 +211,7 @@ namespace LuaScript
|
||||
var t3 = ClampTrack(item.Track3.GetValue(frame, length, fps), layout, 3);
|
||||
|
||||
bool c0 = item.Check0, c1 = item.Check1, c2 = item.Check2, c3 = item.Check3;
|
||||
double s0 = item.Slider0, s1 = item.Slider1, s2 = item.Slider2, s3 = item.Slider3;
|
||||
bool hasColor = item.IsColorVisible;
|
||||
int colorRgb = hasColor ? (item.Color.R << 16) | (item.Color.G << 8) | item.Color.B : 0;
|
||||
|
||||
@@ -182,8 +220,10 @@ namespace LuaScript
|
||||
var key = new RenderKey(
|
||||
frame, time, length, fps,
|
||||
t0, t1, t2, t3,
|
||||
s0, s1, s2, s3,
|
||||
c0, c1, c2, c3, hasColor, colorRgb,
|
||||
script, desc.Usage, desc.SceneId,
|
||||
script, RefreshStringParameters(),
|
||||
desc.Usage, desc.SceneId,
|
||||
desc.TimelinePosition.Frame,
|
||||
desc.TimelinePosition.Time.TotalSeconds,
|
||||
desc.ScreenSize.Width, desc.ScreenSize.Height,
|
||||
@@ -191,6 +231,7 @@ namespace LuaScript
|
||||
desc.GroupIndex, desc.GroupCount,
|
||||
desc.TimelineDuration.Frame,
|
||||
desc.TimelineDuration.Time.TotalSeconds,
|
||||
item.AnchorVersion,
|
||||
inDesc);
|
||||
|
||||
_frameDesc = desc;
|
||||
@@ -213,6 +254,7 @@ namespace LuaScript
|
||||
ctx.SetPixelLoader(() => LoadInputPixels(bounds, imgW, imgH));
|
||||
|
||||
DrawDescription outDesc = inDesc;
|
||||
IReadOnlyList<LuaScriptDiagnostic> diagnostics = [];
|
||||
|
||||
try
|
||||
{
|
||||
@@ -265,6 +307,8 @@ namespace LuaScript
|
||||
}
|
||||
}
|
||||
|
||||
ApplyDrawState(ctx, bounds);
|
||||
|
||||
outDesc = BuildOutputDesc(inDesc, ctx);
|
||||
|
||||
if (ctx.EffectRequests.Count > 0)
|
||||
@@ -280,6 +324,8 @@ namespace LuaScript
|
||||
WarnEffectChainFailureOnce(ex);
|
||||
}
|
||||
}
|
||||
|
||||
outDesc = AddAnchorControllers(outDesc, ctx);
|
||||
}
|
||||
}
|
||||
catch (LuaScriptTimeoutException ex)
|
||||
@@ -288,6 +334,7 @@ namespace LuaScript
|
||||
_context = new AviUtlScriptContext { ResolverProvider = GetFrameResolver };
|
||||
_isFirst = true;
|
||||
Log.Default.Write(ex.Message, ex);
|
||||
LuaScriptDiagnostics.Instance.Report(script, [CreateDiagnostic(LuaScriptDiagnosticKind.Timeout, ex.Message)]);
|
||||
return inDesc;
|
||||
}
|
||||
catch (LuaScriptException ex)
|
||||
@@ -295,6 +342,7 @@ namespace LuaScript
|
||||
effectOutput = null;
|
||||
outDesc = inDesc;
|
||||
Log.Default.Write(ex.Message, ex);
|
||||
diagnostics = [CreateDiagnostic(ClassifyDiagnostic(ex), ex.Message)];
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -302,6 +350,8 @@ namespace LuaScript
|
||||
_pixelLoaderSemaphore.Release();
|
||||
}
|
||||
|
||||
LuaScriptDiagnostics.Instance.Report(script, diagnostics);
|
||||
|
||||
_isFirst = false;
|
||||
_cachedKey = key;
|
||||
_cachedQueries = ctx.ObjectQueries.Count == 0 ? [] : [.. ctx.ObjectQueries];
|
||||
@@ -314,7 +364,8 @@ namespace LuaScript
|
||||
private ID2D1Image ApplyEffectChain(ID2D1Image source, IReadOnlyList<AviUtlEffectRequest> requests, EffectDescription desc, ref DrawDescription drawDescription)
|
||||
{
|
||||
_effectChain ??= new VideoEffectChain(_ownCtx!);
|
||||
return _effectChain.Apply(source, requests, desc, ref drawDescription);
|
||||
var target = AviUtlCompatMap.ResolveTarget(item.Script);
|
||||
return _effectChain.Apply(source, requests, desc, target, ref drawDescription);
|
||||
}
|
||||
|
||||
private static SceneObjectResolver BuildSceneObjectResolver(EffectDescription desc)
|
||||
@@ -364,6 +415,52 @@ namespace LuaScript
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly string[] s_stringParameterNames =
|
||||
[
|
||||
"text", "font", "dir",
|
||||
"file_video", "file_audio", "file_image", "file_project",
|
||||
"file_mp4", "file_exo", "file_subtitle", "file_shader",
|
||||
];
|
||||
|
||||
private readonly string?[] _stringParameterValues = new string?[s_stringParameterNames.Length];
|
||||
private int _stringParametersVersion;
|
||||
|
||||
private int RefreshStringParameters()
|
||||
{
|
||||
var values = _stringParameterValues;
|
||||
bool changed = false;
|
||||
changed |= UpdateStringSlot(values, 0, item.Text);
|
||||
changed |= UpdateStringSlot(values, 1, item.Font);
|
||||
changed |= UpdateStringSlot(values, 2, item.Directory);
|
||||
changed |= UpdateStringSlot(values, 3, item.FileVideo);
|
||||
changed |= UpdateStringSlot(values, 4, item.FileAudio);
|
||||
changed |= UpdateStringSlot(values, 5, item.FileImage);
|
||||
changed |= UpdateStringSlot(values, 6, item.FileProject);
|
||||
changed |= UpdateStringSlot(values, 7, item.FileMp4);
|
||||
changed |= UpdateStringSlot(values, 8, item.FileExo);
|
||||
changed |= UpdateStringSlot(values, 9, item.FileSubtitle);
|
||||
changed |= UpdateStringSlot(values, 10, item.FileShader);
|
||||
if (changed)
|
||||
_stringParametersVersion++;
|
||||
return _stringParametersVersion;
|
||||
}
|
||||
|
||||
private static bool UpdateStringSlot(string?[] values, int index, string value)
|
||||
{
|
||||
if (ReferenceEquals(values[index], value))
|
||||
return false;
|
||||
values[index] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PopulateStringParameters(AviUtlScriptContext ctx)
|
||||
{
|
||||
var names = s_stringParameterNames;
|
||||
var values = _stringParameterValues;
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
ctx.SetStringParameter(names[i], values[i]);
|
||||
}
|
||||
|
||||
private void PopulateContext(AviUtlScriptContext ctx, in RenderKey key, int imgW, int imgH)
|
||||
{
|
||||
var zoom = key.InputDesc.Zoom;
|
||||
@@ -375,6 +472,10 @@ namespace LuaScript
|
||||
ctx.ClearQueries();
|
||||
ctx.ClearEffects();
|
||||
ctx.ClearDraws();
|
||||
ctx.ClearAnchorRequests();
|
||||
ctx.AnchorSource = item.Anchors;
|
||||
ctx.DrawStateOverride = null;
|
||||
ctx.ResetDrawTarget();
|
||||
|
||||
ctx.ImageWidth = imgW;
|
||||
ctx.ImageHeight = imgH;
|
||||
@@ -396,6 +497,10 @@ namespace LuaScript
|
||||
ctx.Track1 = key.Track1;
|
||||
ctx.Track2 = key.Track2;
|
||||
ctx.Track3 = key.Track3;
|
||||
ctx.Slider0 = key.Slider0;
|
||||
ctx.Slider1 = key.Slider1;
|
||||
ctx.Slider2 = key.Slider2;
|
||||
ctx.Slider3 = key.Slider3;
|
||||
ctx.Check0 = key.Check0;
|
||||
ctx.Check1 = key.Check1;
|
||||
ctx.Check2 = key.Check2;
|
||||
@@ -423,6 +528,7 @@ namespace LuaScript
|
||||
ctx.IsPaused = key.Usage == TimelineSourceUsage.Paused;
|
||||
ctx.SceneId = ResolveSceneId(key.SceneId);
|
||||
ctx.TimeRatio = key.Length > 0 ? key.Frame / (double)key.Length : 0d;
|
||||
PopulateStringParameters(ctx);
|
||||
}
|
||||
|
||||
private static double ClampTrack(double value, AviUtlParameterLayout layout, int index)
|
||||
@@ -430,6 +536,143 @@ namespace LuaScript
|
||||
return layout.GetTrack(index) is { } p ? Math.Clamp(value, p.Min, p.Max) : value;
|
||||
}
|
||||
|
||||
private ImmutableList<VideoEffectController> _anchorControllers = ImmutableList<VideoEffectController>.Empty;
|
||||
private AnchorRequestData[] _anchorSignature = [];
|
||||
private IReadOnlyList<LuaAnchorPoint>? _anchorSignatureSource;
|
||||
|
||||
private ImmutableList<VideoEffectController> ResolveAnchorControllers(AviUtlScriptContext ctx)
|
||||
{
|
||||
var requests = ctx.AnchorRequests;
|
||||
if (requests.Count == 0)
|
||||
{
|
||||
_anchorControllers = ImmutableList<VideoEffectController>.Empty;
|
||||
_anchorSignature = [];
|
||||
_anchorSignatureSource = null;
|
||||
return _anchorControllers;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(_anchorSignatureSource, ctx.AnchorSource) && AnchorSignatureMatches(requests))
|
||||
return _anchorControllers;
|
||||
|
||||
_anchorControllers = BuildAnchorControllers(ctx.AnchorSource, requests);
|
||||
_anchorSignature = new AnchorRequestData[requests.Count];
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
_anchorSignature[i] = requests[i];
|
||||
_anchorSignatureSource = ctx.AnchorSource;
|
||||
return _anchorControllers;
|
||||
}
|
||||
|
||||
private bool AnchorSignatureMatches(IReadOnlyList<AnchorRequestData> requests)
|
||||
{
|
||||
if (_anchorSignature.Length != requests.Count)
|
||||
return false;
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
if (!_anchorSignature[i].Equals(requests[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private DrawDescription AddAnchorControllers(DrawDescription desc, AviUtlScriptContext ctx)
|
||||
{
|
||||
var controllers = ResolveAnchorControllers(ctx);
|
||||
return controllers.Count == 0 ? desc : desc with { Controllers = desc.Controllers.AddRange(controllers) };
|
||||
}
|
||||
|
||||
private ImmutableList<VideoEffectController> BuildAnchorControllers(
|
||||
IReadOnlyList<LuaAnchorPoint>? source, IReadOnlyList<AnchorRequestData> requests)
|
||||
{
|
||||
var builder = ImmutableList.CreateBuilder<VideoEffectController>();
|
||||
foreach (var request in requests)
|
||||
{
|
||||
if (request.Count <= 0)
|
||||
continue;
|
||||
|
||||
AddConnectionControllers(builder, source, request);
|
||||
|
||||
var group = request.Group;
|
||||
bool is3D = request.Is3D;
|
||||
for (int i = 0; i < request.Count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, group, i, out double x, out double y, out double z);
|
||||
int index = i;
|
||||
var point = new ControllerPoint(
|
||||
new Vector3((float)x, (float)y, (float)(is3D ? z : 0d)),
|
||||
arg => item.ApplyAnchorDrag(group, index, arg.Delta.X, arg.Delta.Y, is3D ? arg.Delta.Z : 0d))
|
||||
{
|
||||
Shape = VideoControllerPointShape.Circle,
|
||||
};
|
||||
builder.Add(new VideoEffectController(item, [point]));
|
||||
}
|
||||
}
|
||||
return builder.ToImmutable();
|
||||
}
|
||||
|
||||
private void AddConnectionControllers(
|
||||
ImmutableList<VideoEffectController>.Builder builder, IReadOnlyList<LuaAnchorPoint>? source, in AnchorRequestData request)
|
||||
{
|
||||
switch (request.Connection)
|
||||
{
|
||||
case AnchorConnection.Line:
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
break;
|
||||
case AnchorConnection.Loop:
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
if (request.Count >= 2)
|
||||
AddEdge(builder, ConnectionPoint(source, request, request.Count - 1), ConnectionPoint(source, request, 0));
|
||||
break;
|
||||
case AnchorConnection.Star:
|
||||
for (int i = 0; i < request.Count; i++)
|
||||
AddEdge(builder, CenterPoint(), ConnectionPoint(source, request, i));
|
||||
break;
|
||||
case AnchorConnection.Arm:
|
||||
if (request.Count >= 1)
|
||||
AddEdge(builder, CenterPoint(), ConnectionPoint(source, request, 0));
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddEdge(ImmutableList<VideoEffectController>.Builder builder, ControllerPoint a, ControllerPoint b) =>
|
||||
builder.Add(new VideoEffectController(item, [a, b]) { Connection = VideoControllerPointConnection.Line });
|
||||
|
||||
private static ControllerPoint CenterPoint() =>
|
||||
new(Vector3.Zero) { Shape = VideoControllerPointShape.None };
|
||||
|
||||
private static ControllerPoint ConnectionPoint(IReadOnlyList<LuaAnchorPoint>? source, in AnchorRequestData request, int index)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, request.Group, index, out double x, out double y, out double z);
|
||||
return new ControllerPoint(new Vector3((float)x, (float)y, (float)(request.Is3D ? z : 0d)))
|
||||
{
|
||||
Shape = VideoControllerPointShape.None,
|
||||
};
|
||||
}
|
||||
|
||||
private void ApplyDrawState(AviUtlScriptContext ctx, RawRectF bounds)
|
||||
{
|
||||
if (ctx.DrawStateOverride is not { } drawn)
|
||||
return;
|
||||
|
||||
if (!drawn)
|
||||
{
|
||||
effectOutput = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (effectOutput is not null)
|
||||
return;
|
||||
|
||||
ctx.EnsurePixelBuffer();
|
||||
var buffer = ctx.GetPixelBuffer();
|
||||
if (buffer is null)
|
||||
return;
|
||||
|
||||
_pixelManager!.WritePixelsToOutput(buffer, ctx.ImageWidth, ctx.ImageHeight);
|
||||
effectOutput = _pixelManager.GetTransformOutput(bounds.Left, bounds.Top);
|
||||
}
|
||||
|
||||
private static DrawDescription BuildOutputDesc(DrawDescription inDesc, AviUtlScriptContext ctx)
|
||||
{
|
||||
return inDesc with
|
||||
@@ -540,7 +783,7 @@ namespace LuaScript
|
||||
byte[] buffer = LoadInputPixels(bounds, imgW, imgH);
|
||||
|
||||
bool ok = _nativeWorker.Execute(
|
||||
script, _nativeFields, buffer, imgW, imgH, NativeTimeoutMilliseconds,
|
||||
script, _nativeFields, ctx.StringParameters, buffer, imgW, imgH, NativeTimeoutMilliseconds,
|
||||
(tag, frame) => ctx.ResolveObject(tag, frame, out var info) ? info : null,
|
||||
NativeLoadFigure,
|
||||
NativeLoadText,
|
||||
@@ -548,6 +791,7 @@ namespace LuaScript
|
||||
NativeLoadMovie,
|
||||
(name, args) => ctx.AddEffect(new AviUtlEffectRequest(name, args)),
|
||||
ctx.AddDraw,
|
||||
ResolveNativeAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels,
|
||||
out int resultW, out int resultH, out string? error);
|
||||
|
||||
@@ -598,6 +842,22 @@ namespace LuaScript
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ResolveNativeAnchor(string group, int count, bool is3D, int connection, double[] positions)
|
||||
{
|
||||
_context.AddAnchorRequest(new AnchorRequestData(group, count, (AnchorConnection)connection, is3D));
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
var source = _context.AnchorSource;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, group, i, out double x, out double y, out double z);
|
||||
positions[i * stride + 0] = x;
|
||||
positions[i * stride + 1] = y;
|
||||
if (is3D)
|
||||
positions[i * stride + 2] = z;
|
||||
}
|
||||
}
|
||||
|
||||
private (byte[] buffer, int w, int h) NativeLoadText(string family, string text, double size, bool bold, bool italic, int color)
|
||||
{
|
||||
_nativeTextRenderer ??= new TextRenderer();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using MoonSharp.Interpreter;
|
||||
using MoonSharp.Interpreter.Debugging;
|
||||
@@ -333,6 +334,12 @@ namespace LuaScript
|
||||
_objTable!["track1"] = ctx.Track1;
|
||||
_objTable!["track2"] = ctx.Track2;
|
||||
_objTable!["track3"] = ctx.Track3;
|
||||
_objTable!["slider0"] = ctx.Slider0;
|
||||
_objTable!["slider1"] = ctx.Slider1;
|
||||
_objTable!["slider2"] = ctx.Slider2;
|
||||
_objTable!["slider3"] = ctx.Slider3;
|
||||
foreach (var parameter in ctx.StringParameters)
|
||||
_objTable![parameter.Key] = parameter.Value;
|
||||
_objTable!["check0"] = ctx.Check0;
|
||||
_objTable!["check1"] = ctx.Check1;
|
||||
_objTable!["check2"] = ctx.Check2;
|
||||
@@ -581,7 +588,7 @@ namespace LuaScript
|
||||
double alpha = args.Count > 4 ? args[4].CastToNumber() ?? 1d : 1d;
|
||||
double aspect = args.Count > 5 ? args[5].CastToNumber() ?? 0d : 0d;
|
||||
|
||||
_activeContext.AddDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, CurrentAntialias()));
|
||||
_activeContext.SubmitDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, CurrentAntialias(), CurrentBlend()));
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -617,7 +624,7 @@ namespace LuaScript
|
||||
_ => 1d,
|
||||
};
|
||||
|
||||
_activeContext.AddDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, CurrentAntialias()));
|
||||
_activeContext.SubmitDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, CurrentAntialias(), CurrentBlend()));
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -642,12 +649,68 @@ namespace LuaScript
|
||||
return value.Type == DataType.Number ? value : DynValue.NewNumber(0d);
|
||||
});
|
||||
|
||||
obj["setanchor"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
if (_activeContext is null || _script is null || args.Count < 2 || args[0].Type != DataType.String)
|
||||
return DynValue.NewNumber(0d);
|
||||
|
||||
var anchorName = args[0].String;
|
||||
int count = AnchorSupport.ClampCount((int)(args[1].CastToNumber() ?? 0d));
|
||||
if (string.Equals(anchorName, AnchorSupport.TrackGroup, StringComparison.Ordinal))
|
||||
return DynValue.NewNumber(0d);
|
||||
|
||||
var connection = AnchorConnection.None;
|
||||
bool is3D = false;
|
||||
for (int i = 2; i < args.Count; i++)
|
||||
{
|
||||
if (args[i].Type == DataType.String)
|
||||
AnchorSupport.ApplyOption(args[i].String, ref connection, ref is3D);
|
||||
}
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
var table = new Table(_script);
|
||||
var source = _activeContext.AnchorSource;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, anchorName, i, out double x, out double y, out double z);
|
||||
table.Set(i * stride + 1, DynValue.NewNumber(x));
|
||||
table.Set(i * stride + 2, DynValue.NewNumber(y));
|
||||
if (is3D)
|
||||
table.Set(i * stride + 3, DynValue.NewNumber(z));
|
||||
}
|
||||
_script.Globals.Set(anchorName, DynValue.NewTable(table));
|
||||
|
||||
_activeContext.AddAnchorRequest(new AnchorRequestData(anchorName, count, connection, is3D));
|
||||
return DynValue.NewNumber(count);
|
||||
});
|
||||
|
||||
obj["setoption"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
if (args.Count == 0 || args[0].Type != DataType.String)
|
||||
return DynValue.Void;
|
||||
_options[args[0].String] = args.Count > 1 ? args[1] : DynValue.True;
|
||||
var name = args[0].String;
|
||||
var value = args.Count > 1 ? args[1] : DynValue.True;
|
||||
_options[name] = value;
|
||||
if (name == "draw_state" && _activeContext is not null)
|
||||
_activeContext.DrawStateOverride = value.Type == DataType.Boolean
|
||||
? value.Boolean
|
||||
: (value.CastToNumber() ?? 0d) != 0d;
|
||||
if (name == "drawtarget" && _activeContext is not null)
|
||||
{
|
||||
if (value.Type == DataType.String && value.String == "tempbuffer")
|
||||
{
|
||||
bool hasSize = args.Count > 3;
|
||||
int w = hasSize ? (int)(args[2].CastToNumber() ?? 0d) : 0;
|
||||
int h = hasSize ? (int)(args[3].CastToNumber() ?? 0d) : 0;
|
||||
_activeContext.SetDrawTarget(true, w, h, hasSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
_activeContext.SetDrawTarget(false, 0, 0, false);
|
||||
}
|
||||
}
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -674,6 +737,11 @@ namespace LuaScript
|
||||
? value.Number
|
||||
: 1d;
|
||||
|
||||
private double CurrentBlend() =>
|
||||
_options.TryGetValue("blend", out var value) && value.Type == DataType.Number
|
||||
? value.Number
|
||||
: 0d;
|
||||
|
||||
private void LoadFigure(string name, int color, double size, double line, double aspect)
|
||||
{
|
||||
int boundingSize = Math.Max(1, (int)Math.Round(size));
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal static class SoftwareCompositor
|
||||
{
|
||||
public static void DrawInto(
|
||||
byte[] dst, int dstW, int dstH,
|
||||
byte[] src, int srcW, int srcH,
|
||||
double ox, double oy, double zoom, double aspect, double alpha, bool linear)
|
||||
{
|
||||
if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0)
|
||||
return;
|
||||
|
||||
double clampedAspect = Math.Clamp(aspect, -1d, 1d);
|
||||
double zx = zoom * (1d + clampedAspect);
|
||||
double zy = zoom * (1d - clampedAspect);
|
||||
if (zx == 0d || zy == 0d)
|
||||
return;
|
||||
|
||||
double ka = Math.Clamp(alpha, 0d, 1d);
|
||||
if (ka <= 0d)
|
||||
return;
|
||||
|
||||
double halfW = srcW * 0.5;
|
||||
double halfH = srcH * 0.5;
|
||||
double spanX = Math.Abs(halfW * zx);
|
||||
double spanY = Math.Abs(halfH * zy);
|
||||
|
||||
int x0 = Math.Max(0, (int)Math.Floor(ox - spanX));
|
||||
int x1 = Math.Min(dstW - 1, (int)Math.Ceiling(ox + spanX));
|
||||
int y0 = Math.Max(0, (int)Math.Floor(oy - spanY));
|
||||
int y1 = Math.Min(dstH - 1, (int)Math.Ceiling(oy + spanY));
|
||||
|
||||
for (int py = y0; py <= y1; py++)
|
||||
{
|
||||
for (int px = x0; px <= x1; px++)
|
||||
{
|
||||
double u = (px + 0.5 - ox) / zx + halfW;
|
||||
double v = (py + 0.5 - oy) / zy + halfH;
|
||||
if (u < 0d || u >= srcW || v < 0d || v >= srcH)
|
||||
continue;
|
||||
|
||||
Sample(src, srcW, srcH, u, v, linear, out double sb, out double sg, out double sr, out double sa);
|
||||
CompositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawPolyInto(
|
||||
byte[] dst, int dstW, int dstH,
|
||||
byte[] src, int srcW, int srcH,
|
||||
double[] poly, double alpha, bool linear)
|
||||
{
|
||||
if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0)
|
||||
return;
|
||||
if (!DrawPolyMath.TrySolveAffine(poly, out var forward))
|
||||
return;
|
||||
if (!Matrix3x2.Invert(forward, out var inverse))
|
||||
return;
|
||||
|
||||
double ka = Math.Clamp(alpha, 0d, 1d);
|
||||
if (ka <= 0d)
|
||||
return;
|
||||
|
||||
DrawPolyMath.Bounds(poly, out double minX, out double minY, out double maxX, out double maxY);
|
||||
int x0 = Math.Max(0, (int)Math.Floor(minX));
|
||||
int x1 = Math.Min(dstW - 1, (int)Math.Ceiling(maxX));
|
||||
int y0 = Math.Max(0, (int)Math.Floor(minY));
|
||||
int y1 = Math.Min(dstH - 1, (int)Math.Ceiling(maxY));
|
||||
|
||||
for (int py = y0; py <= y1; py++)
|
||||
{
|
||||
for (int px = x0; px <= x1; px++)
|
||||
{
|
||||
var uv = Vector2.Transform(new Vector2(px + 0.5f, py + 0.5f), inverse);
|
||||
double u = uv.X;
|
||||
double v = uv.Y;
|
||||
if (u < 0d || u >= srcW || v < 0d || v >= srcH)
|
||||
continue;
|
||||
|
||||
Sample(src, srcW, srcH, u, v, linear, out double sb, out double sg, out double sr, out double sa);
|
||||
CompositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Sample(byte[] src, int srcW, int srcH, double u, double v, bool linear,
|
||||
out double b, out double g, out double r, out double a)
|
||||
{
|
||||
if (!linear)
|
||||
{
|
||||
int su = Math.Clamp((int)Math.Floor(u), 0, srcW - 1);
|
||||
int sv = Math.Clamp((int)Math.Floor(v), 0, srcH - 1);
|
||||
int si = (sv * srcW + su) * 4;
|
||||
b = src[si];
|
||||
g = src[si + 1];
|
||||
r = src[si + 2];
|
||||
a = src[si + 3];
|
||||
return;
|
||||
}
|
||||
|
||||
double fx = u - 0.5;
|
||||
double fy = v - 0.5;
|
||||
int x0 = (int)Math.Floor(fx);
|
||||
int y0 = (int)Math.Floor(fy);
|
||||
double tx = fx - x0;
|
||||
double ty = fy - y0;
|
||||
|
||||
b = g = r = a = 0d;
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
int sy = Math.Clamp(y0 + j, 0, srcH - 1);
|
||||
double wy = j == 0 ? 1d - ty : ty;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int sx = Math.Clamp(x0 + i, 0, srcW - 1);
|
||||
double w = wy * (i == 0 ? 1d - tx : tx);
|
||||
int si = (sy * srcW + sx) * 4;
|
||||
b += src[si] * w;
|
||||
g += src[si + 1] * w;
|
||||
r += src[si + 2] * w;
|
||||
a += src[si + 3] * w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CompositeOver(byte[] dst, int di, double sb, double sg, double sr, double sa)
|
||||
{
|
||||
double inv = 1d - sa / 255d;
|
||||
dst[di] = (byte)Math.Clamp(sb + dst[di] * inv, 0d, 255d);
|
||||
dst[di + 1] = (byte)Math.Clamp(sg + dst[di + 1] * inv, 0d, 255d);
|
||||
dst[di + 2] = (byte)Math.Clamp(sr + dst[di + 2] * inv, 0d, 255d);
|
||||
dst[di + 3] = (byte)Math.Clamp(sa + dst[di + 3] * inv, 0d, 255d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>مسار 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>مسار 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>قيمة المنزلق (متوافق مع AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>منزلق 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>منزلق 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>منزلق 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>منزلق 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>منزلق رقمي (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>خانة 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>خانة 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>خانة 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>قيمة خانة الاختيار (متوافق مع AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>اللون</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>اللون (متوافق مع AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>نص</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>إدخال نص (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>خط</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>اختيار الخط (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>مجلد</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>اختيار المجلد (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>اختيار الملف (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>ملف فيديو</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>ملف صوتي</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>ملف صورة</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>ملف المشروع</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>ملف MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>ملف EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>ملف الترجمة</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>ملف التظليل</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>استيراد</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>تصدير</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>مسح</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>خطأ في الاستيراد</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>خطأ في التصدير</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>نص Lua (*.lua)|*.lua|جميع الملفات (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>خطأ في بناء الجملة</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>خطأ وقت التشغيل</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>انتهت المهلة</value></data>
|
||||
</root>
|
||||
@@ -9,6 +9,11 @@ Track1,,トラック1,Track 1,轨道1,軌道1,트랙1,Pista 1,مسار 1,Jalur 1
|
||||
Track2,,トラック2,Track 2,轨道2,軌道2,트랙2,Pista 2,مسار 2,Jalur 2
|
||||
Track3,,トラック3,Track 3,轨道3,軌道3,트랙3,Pista 3,مسار 3,Jalur 3
|
||||
TrackDesc,,スライダー値 (AviUtl準拠 track0〜3 に対応),Slider value (AviUtl compatible: track0–3),滑块值(AviUtl兼容: track0~3),滑塊值(AviUtl兼容: track0~3),슬라이더 값 (AviUtl 호환: track0~3),Valor del deslizador (compatible AviUtl: track0-3),قيمة المنزلق (متوافق مع AviUtl: track0-3),Nilai slider (kompatibel AviUtl: track0-3)
|
||||
Slider0,,スライダー0,Slider 0,滑块0,滑塊0,슬라이더0,Deslizador 0,منزلق 0,Slider 0
|
||||
Slider1,,スライダー1,Slider 1,滑块1,滑塊1,슬라이더1,Deslizador 1,منزلق 1,Slider 1
|
||||
Slider2,,スライダー2,Slider 2,滑块2,滑塊2,슬라이더2,Deslizador 2,منزلق 2,Slider 2
|
||||
Slider3,,スライダー3,Slider 3,滑块3,滑塊3,슬라이더3,Deslizador 3,منزلق 3,Slider 3
|
||||
SliderDesc,,数値スライダー (obj.slider0〜3 で参照),Numeric slider (obj.slider0–3),数值滑块 (obj.slider0~3),數值滑塊 (obj.slider0~3),숫자 슬라이더 (obj.slider0~3),Deslizador numérico (obj.slider0-3),منزلق رقمي (obj.slider0-3),Slider numerik (obj.slider0-3)
|
||||
Check0,,チェック0,Check 0,复选框0,核取方塊0,체크0,Casilla 0,خانة 0,Centang 0
|
||||
Check1,,チェック1,Check 1,复选框1,核取方塊1,체크1,Casilla 1,خانة 1,Centang 1
|
||||
Check2,,チェック2,Check 2,复选框2,核取方塊2,체크2,Casilla 2,خانة 2,Centang 2
|
||||
@@ -16,6 +21,21 @@ Check3,,チェック3,Check 3,复选框3,核取方塊3,체크3,Casilla 3,خان
|
||||
CheckDesc,,チェックボックス値 (AviUtl準拠 check0〜3 に対応),Checkbox value (AviUtl compatible: check0–3),复选框值(AviUtl兼容: check0~3),核取方塊值(AviUtl兼容: check0~3),체크박스 값 (AviUtl 호환: check0~3),Valor de casilla (compatible AviUtl: check0-3),قيمة خانة الاختيار (متوافق مع AviUtl: check0-3),Nilai kotak centang (kompatibel AviUtl: check0-3)
|
||||
Color,,色,Color,颜色,顏色,색,Color,اللون,Warna
|
||||
ColorDesc,,色 (AviUtl準拠 --color に対応),Color (AviUtl compatible: --color),颜色(AviUtl兼容: --color),顏色(AviUtl兼容: --color),색 (AviUtl 호환: --color),Color (compatible AviUtl: --color),اللون (متوافق مع AviUtl: --color),Warna (kompatibel AviUtl: --color)
|
||||
Text,,テキスト,Text,文本,文字,텍스트,Texto,نص,Teks
|
||||
TextDesc,,テキスト入力 (obj.text で参照),Text input (obj.text),文本输入 (obj.text),文字輸入 (obj.text),텍스트 입력 (obj.text),Entrada de texto (obj.text),إدخال نص (obj.text),Masukan teks (obj.text)
|
||||
Font,,フォント,Font,字体,字型,글꼴,Fuente,خط,Font
|
||||
FontDesc,,フォント選択 (obj.font で参照),Font selection (obj.font),字体选择 (obj.font),字型選擇 (obj.font),글꼴 선택 (obj.font),Selección de fuente (obj.font),اختيار الخط (obj.font),Pilihan font (obj.font)
|
||||
Directory,,フォルダ,Folder,文件夹,資料夾,폴더,Carpeta,مجلد,Folder
|
||||
DirectoryDesc,,フォルダ選択 (obj.dir で参照),Folder selection (obj.dir),文件夹选择 (obj.dir),資料夾選擇 (obj.dir),폴더 선택 (obj.dir),Selección de carpeta (obj.dir),اختيار المجلد (obj.dir),Pilihan folder (obj.dir)
|
||||
FileDesc,,ファイル選択 (obj.file_* で参照),File selection (obj.file_*),文件选择 (obj.file_*),檔案選擇 (obj.file_*),파일 선택 (obj.file_*),Selección de archivo (obj.file_*),اختيار الملف (obj.file_*),Pilihan file (obj.file_*)
|
||||
FileVideo,,動画ファイル,Video File,视频文件,影片檔案,동영상 파일,Archivo de video,ملف فيديو,File Video
|
||||
FileAudio,,音声ファイル,Audio File,音频文件,音訊檔案,음성 파일,Archivo de audio,ملف صوتي,File Audio
|
||||
FileImage,,画像ファイル,Image File,图像文件,圖片檔案,이미지 파일,Archivo de imagen,ملف صورة,File Gambar
|
||||
FileProject,,プロジェクトファイル,Project File,项目文件,專案檔案,프로젝트 파일,Archivo de proyecto,ملف المشروع,File Proyek
|
||||
FileMp4,,MP4ファイル,MP4 File,MP4文件,MP4檔案,MP4 파일,Archivo MP4,ملف MP4,File MP4
|
||||
FileExo,,EXOファイル,EXO File,EXO文件,EXO檔案,EXO 파일,Archivo EXO,ملف EXO,File EXO
|
||||
FileSubtitle,,字幕ファイル,Subtitle File,字幕文件,字幕檔案,자막 파일,Archivo de subtítulos,ملف الترجمة,File Subtitle
|
||||
FileShader,,シェーダーファイル,Shader File,着色器文件,著色器檔案,셰이더 파일,Archivo de sombreador,ملف التظليل,File Shader
|
||||
ToolBarImport,,インポート,Import,导入,導入,가져오기,Importar,استيراد,Impor
|
||||
ToolBarExport,,エクスポート,Export,导出,導出,내보내기,Exportar,تصدير,Ekspor
|
||||
ToolBarClear,,クリア,Clear,清除,清除,지우기,Limpiar,مسح,Hapus
|
||||
@@ -24,3 +44,6 @@ ToolBarClearTitle,,確認,Confirm,确认,確認,확인,Confirmar,تأكيد,Konf
|
||||
ToolBarImportErrorTitle,,インポートエラー,Import Error,导入错误,導入錯誤,가져오기 오류,Error de importación,خطأ في الاستيراد,Kesalahan impor
|
||||
ToolBarExportErrorTitle,,エクスポートエラー,Export Error,导出错误,導出錯誤,내보내기 오류,Error de exportación,خطأ في التصدير,Kesalahan ekspor
|
||||
LuaFileFilter,,Luaスクリプト (*.lua)|*.lua|すべてのファイル (*.*)|*.*,Lua Script (*.lua)|*.lua|All Files (*.*)|*.*,Lua脚本 (*.lua)|*.lua|所有文件 (*.*)|*.*,Lua腳本 (*.lua)|*.lua|所有檔案 (*.*)|*.*,Lua 스크립트 (*.lua)|*.lua|모든 파일 (*.*)|*.*,Script Lua (*.lua)|*.lua|Todos los archivos (*.*)|*.*,نص Lua (*.lua)|*.lua|جميع الملفات (*.*)|*.*,Skrip Lua (*.lua)|*.lua|Semua File (*.*)|*.*
|
||||
DiagnosticCompile,,構文エラー,Syntax error,语法错误,語法錯誤,구문 오류,Error de sintaxis,خطأ في بناء الجملة,Kesalahan sintaksis
|
||||
DiagnosticRuntime,,実行時エラー,Runtime error,运行时错误,執行時錯誤,런타임 오류,Error de ejecución,خطأ وقت التشغيل,Kesalahan runtime
|
||||
DiagnosticTimeout,,タイムアウト,Timed out,执行超时,執行逾時,시간 초과,Tiempo de espera agotado,انتهت المهلة,Waktu habis
|
||||
|
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Track 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Track 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Slider value (AviUtl compatible: track0–3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Slider 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Slider 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Slider 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Slider 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Numeric slider (obj.slider0–3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Check 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Check 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Check 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Checkbox value (AviUtl compatible: check0–3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Color</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Color (AviUtl compatible: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Text</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Text input (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Font</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Font selection (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Folder</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Folder selection (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>File selection (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>Video File</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>Audio File</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>Image File</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>Project File</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4 File</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO File</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>Subtitle File</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>Shader File</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Import</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Export</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Clear</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>Import Error</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>Export Error</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Lua Script (*.lua)|*.lua|All Files (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>Syntax error</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>Runtime error</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>Timed out</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Pista 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Pista 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Valor del deslizador (compatible AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Deslizador 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Deslizador 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Deslizador 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Deslizador 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Deslizador numérico (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Casilla 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Casilla 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Casilla 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Valor de casilla (compatible AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Color</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Color (compatible AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Texto</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Entrada de texto (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Fuente</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Selección de fuente (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Carpeta</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Selección de carpeta (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>Selección de archivo (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>Archivo de video</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>Archivo de audio</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>Archivo de imagen</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>Archivo de proyecto</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>Archivo MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>Archivo EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>Archivo de subtítulos</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>Archivo de sombreador</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Importar</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Exportar</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Limpiar</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>Error de importación</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>Error de exportación</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Script Lua (*.lua)|*.lua|Todos los archivos (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>Error de sintaxis</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>Error de ejecución</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>Tiempo de espera agotado</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Jalur 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Jalur 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Nilai slider (kompatibel AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Slider 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Slider 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Slider 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Slider 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Slider numerik (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Centang 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Centang 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Centang 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Nilai kotak centang (kompatibel AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Warna</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Warna (kompatibel AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Teks</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Masukan teks (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Font</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Pilihan font (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Folder</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Pilihan folder (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>Pilihan file (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>File Video</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>File Audio</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>File Gambar</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>File Proyek</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>File MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>File EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>File Subtitle</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>File Shader</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Impor</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Ekspor</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Hapus</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>Kesalahan impor</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>Kesalahan ekspor</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Skrip Lua (*.lua)|*.lua|Semua File (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>Kesalahan sintaksis</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>Kesalahan runtime</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>Waktu habis</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>트랙2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>트랙3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>슬라이더 값 (AviUtl 호환: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>슬라이더0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>슬라이더1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>슬라이더2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>슬라이더3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>숫자 슬라이더 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>체크0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>체크1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>체크2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>체크박스 값 (AviUtl 호환: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>색</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>색 (AviUtl 호환: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>텍스트</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>텍스트 입력 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>글꼴</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>글꼴 선택 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>폴더</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>폴더 선택 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>파일 선택 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>동영상 파일</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>음성 파일</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>이미지 파일</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>프로젝트 파일</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4 파일</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO 파일</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>자막 파일</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>셰이더 파일</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>가져오기</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>내보내기</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>지우기</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>가져오기 오류</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>내보내기 오류</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Lua 스크립트 (*.lua)|*.lua|모든 파일 (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>구문 오류</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>런타임 오류</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>시간 초과</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>トラック2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>トラック3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>スライダー値 (AviUtl準拠 track0〜3 に対応)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>スライダー0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>スライダー1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>スライダー2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>スライダー3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>数値スライダー (obj.slider0〜3 で参照)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>チェック0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>チェック1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>チェック2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>チェックボックス値 (AviUtl準拠 check0〜3 に対応)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>色 (AviUtl準拠 --color に対応)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>テキスト</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>テキスト入力 (obj.text で参照)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>フォント</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>フォント選択 (obj.font で参照)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>フォルダ</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>フォルダ選択 (obj.dir で参照)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>ファイル選択 (obj.file_* で参照)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>動画ファイル</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音声ファイル</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>画像ファイル</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>プロジェクトファイル</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4ファイル</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXOファイル</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕ファイル</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>シェーダーファイル</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>インポート</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>エクスポート</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>クリア</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>インポートエラー</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>エクスポートエラー</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Luaスクリプト (*.lua)|*.lua|すべてのファイル (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>構文エラー</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>実行時エラー</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>タイムアウト</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>轨道2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>轨道3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>滑块值(AviUtl兼容: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>滑块0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>滑块1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>滑块2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>滑块3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>数值滑块 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>复选框0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>复选框1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>复选框2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>复选框值(AviUtl兼容: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>颜色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>颜色(AviUtl兼容: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>文本</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>文本输入 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>字体</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>字体选择 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>文件夹</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>文件夹选择 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>文件选择 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>视频文件</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音频文件</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>图像文件</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>项目文件</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4文件</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO文件</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕文件</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>着色器文件</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>导入</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>导出</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>清除</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>导入错误</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>导出错误</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Lua脚本 (*.lua)|*.lua|所有文件 (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>语法错误</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>运行时错误</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>执行超时</value></data>
|
||||
</root>
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>軌道2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>軌道3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>滑塊值(AviUtl兼容: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>滑塊0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>滑塊1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>滑塊2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>滑塊3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>數值滑塊 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>核取方塊0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>核取方塊1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>核取方塊2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>核取方塊值(AviUtl兼容: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>顏色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>顏色(AviUtl兼容: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>文字</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>文字輸入 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>字型</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>字型選擇 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>資料夾</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>資料夾選擇 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>檔案選擇 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>影片檔案</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音訊檔案</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>圖片檔案</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>專案檔案</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4檔案</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO檔案</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕檔案</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>著色器檔案</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>導入</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>導出</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>清除</value></data>
|
||||
@@ -84,4 +104,7 @@
|
||||
<data name="ToolBarImportErrorTitle" xml:space="preserve"><value>導入錯誤</value></data>
|
||||
<data name="ToolBarExportErrorTitle" xml:space="preserve"><value>導出錯誤</value></data>
|
||||
<data name="LuaFileFilter" xml:space="preserve"><value>Lua腳本 (*.lua)|*.lua|所有檔案 (*.*)|*.*</value></data>
|
||||
<data name="DiagnosticCompile" xml:space="preserve"><value>語法錯誤</value></data>
|
||||
<data name="DiagnosticRuntime" xml:space="preserve"><value>執行時錯誤</value></data>
|
||||
<data name="DiagnosticTimeout" xml:space="preserve"><value>執行逾時</value></data>
|
||||
</root>
|
||||
+71
-29
@@ -9,6 +9,7 @@ using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Player.Video;
|
||||
using YukkuriMovieMaker.Plugin;
|
||||
using YukkuriMovieMaker.Plugin.Effects;
|
||||
using LuaScript.Compat;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
@@ -16,29 +17,33 @@ namespace LuaScript
|
||||
{
|
||||
private sealed class Node
|
||||
{
|
||||
public required Type Type;
|
||||
public required IVideoEffect Model;
|
||||
public required IVideoEffectProcessor Processor;
|
||||
public required AviUtlEffectMapping? Mapping;
|
||||
public required int RequestIndex;
|
||||
}
|
||||
|
||||
private static Dictionary<string, Type>? _registry;
|
||||
private static readonly AviUtlParameterMapping Identity = new(string.Empty, string.Empty, 1d, 0d);
|
||||
|
||||
private static Dictionary<string, Type>? _typeRegistry;
|
||||
private static Dictionary<string, Type>? _nameRegistry;
|
||||
private static readonly Dictionary<Type, Dictionary<string, PropertyInfo>> _propertyCache = [];
|
||||
|
||||
private readonly IGraphicsDevicesAndContext _devices;
|
||||
private readonly List<Node> _nodes = [];
|
||||
private string[] _signature = [];
|
||||
private AviUtlEngine _signatureTarget = AviUtlEngine.Both;
|
||||
|
||||
public VideoEffectChain(IGraphicsDevicesAndContext devices)
|
||||
{
|
||||
_devices = devices;
|
||||
}
|
||||
|
||||
public ID2D1Image Apply(ID2D1Image source, IReadOnlyList<AviUtlEffectRequest> requests, EffectDescription baseDesc, ref DrawDescription drawDescription)
|
||||
public ID2D1Image Apply(ID2D1Image source, IReadOnlyList<AviUtlEffectRequest> requests, EffectDescription baseDesc, AviUtlEngine target, ref DrawDescription drawDescription)
|
||||
{
|
||||
try
|
||||
{
|
||||
SyncNodes(requests);
|
||||
SyncNodes(requests, target);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -52,7 +57,7 @@ namespace LuaScript
|
||||
{
|
||||
try
|
||||
{
|
||||
ApplyParameters(node.Model, requests[node.RequestIndex].Arguments);
|
||||
ApplyParameters(node.Model, node.Mapping, requests[node.RequestIndex].Arguments);
|
||||
node.Processor.SetInput(current);
|
||||
var effectDescription = new EffectDescription(baseDesc, desc, baseDesc.InputIndex, baseDesc.InputCount, baseDesc.GroupIndex, baseDesc.GroupCount);
|
||||
desc = node.Processor.Update(effectDescription);
|
||||
@@ -67,19 +72,32 @@ namespace LuaScript
|
||||
return current;
|
||||
}
|
||||
|
||||
private void SyncNodes(IReadOnlyList<AviUtlEffectRequest> requests)
|
||||
private void SyncNodes(IReadOnlyList<AviUtlEffectRequest> requests, AviUtlEngine target)
|
||||
{
|
||||
if (SignatureMatches(requests))
|
||||
if (SignatureMatches(requests, target))
|
||||
return;
|
||||
|
||||
DisposeNodes();
|
||||
_signatureTarget = target;
|
||||
_signature = new string[requests.Count];
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
_signature[i] = requests[i].Name;
|
||||
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
var type = Resolve(requests[i].Name);
|
||||
Type? type;
|
||||
AviUtlEffectMapping? mapping;
|
||||
if (AviUtlCompatMap.Default.TryResolve(requests[i].Name, target, out var resolved) &&
|
||||
ResolveType(resolved.TargetType) is { } mappedType)
|
||||
{
|
||||
mapping = resolved;
|
||||
type = mappedType;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapping = null;
|
||||
type = ResolveName(requests[i].Name);
|
||||
}
|
||||
if (type is null)
|
||||
continue;
|
||||
|
||||
@@ -104,13 +122,13 @@ namespace LuaScript
|
||||
continue;
|
||||
}
|
||||
|
||||
_nodes.Add(new Node { Type = type, Model = model, Processor = processor, RequestIndex = i });
|
||||
_nodes.Add(new Node { Model = model, Processor = processor, Mapping = mapping, RequestIndex = i });
|
||||
}
|
||||
}
|
||||
|
||||
private bool SignatureMatches(IReadOnlyList<AviUtlEffectRequest> requests)
|
||||
private bool SignatureMatches(IReadOnlyList<AviUtlEffectRequest> requests, AviUtlEngine target)
|
||||
{
|
||||
if (_signature.Length != requests.Count)
|
||||
if (_signatureTarget != target || _signature.Length != requests.Count)
|
||||
return false;
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
@@ -120,38 +138,49 @@ namespace LuaScript
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Type? Resolve(string name)
|
||||
private static Type? ResolveType(string targetType)
|
||||
{
|
||||
var registry = GetRegistry();
|
||||
return registry.TryGetValue(Normalize(name), out var type) ? type : null;
|
||||
EnsureRegistries();
|
||||
return _typeRegistry!.TryGetValue(Normalize(targetType), out var type) ? type : null;
|
||||
}
|
||||
|
||||
private static Dictionary<string, Type> GetRegistry()
|
||||
private static Type? ResolveName(string name)
|
||||
{
|
||||
if (_registry is not null)
|
||||
return _registry;
|
||||
EnsureRegistries();
|
||||
return _nameRegistry!.TryGetValue(Normalize(name), out var type) ? type : null;
|
||||
}
|
||||
|
||||
var map = new Dictionary<string, Type>(StringComparer.Ordinal);
|
||||
private static void EnsureRegistries()
|
||||
{
|
||||
if (_typeRegistry is not null && _nameRegistry is not null)
|
||||
return;
|
||||
|
||||
var byType = new Dictionary<string, Type>(StringComparer.Ordinal);
|
||||
var byName = new Dictionary<string, Type>(StringComparer.Ordinal);
|
||||
try
|
||||
{
|
||||
foreach (var factory in EffectFactories.VideoEffectFactories)
|
||||
{
|
||||
try
|
||||
{
|
||||
Register(map, factory.Name, factory.EffectType);
|
||||
var type = factory.EffectType;
|
||||
if (type is null)
|
||||
continue;
|
||||
byType.TryAdd(Normalize(type.Name), type);
|
||||
Register(byName, factory.Name, type);
|
||||
foreach (var keyword in factory.Keywords)
|
||||
Register(map, keyword, factory.EffectType);
|
||||
Register(byName, keyword, type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
_registry = map;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return map;
|
||||
_typeRegistry = byType;
|
||||
_nameRegistry = byName;
|
||||
}
|
||||
|
||||
private static void Register(Dictionary<string, Type> map, string? key, Type type)
|
||||
@@ -163,7 +192,7 @@ namespace LuaScript
|
||||
|
||||
private static string Normalize(string value) => value.Trim().ToLowerInvariant();
|
||||
|
||||
private static void ApplyParameters(IVideoEffect model, IReadOnlyList<KeyValuePair<string, object>> arguments)
|
||||
private static void ApplyParameters(IVideoEffect model, AviUtlEffectMapping? mapping, IReadOnlyList<KeyValuePair<string, object>> arguments)
|
||||
{
|
||||
if (arguments.Count == 0)
|
||||
return;
|
||||
@@ -171,11 +200,24 @@ namespace LuaScript
|
||||
var properties = GetProperties(model.GetType());
|
||||
foreach (var (key, value) in arguments)
|
||||
{
|
||||
if (!properties.TryGetValue(Normalize(key), out var property))
|
||||
continue;
|
||||
PropertyInfo? property;
|
||||
AviUtlParameterMapping parameter;
|
||||
if (mapping is not null)
|
||||
{
|
||||
if (!mapping.TryGetParameter(key, out parameter) ||
|
||||
!properties.TryGetValue(Normalize(parameter.Property), out property))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!properties.TryGetValue(Normalize(key), out property))
|
||||
continue;
|
||||
parameter = Identity;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SetValue(model, property, value);
|
||||
SetValue(model, property, value, parameter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -213,14 +255,14 @@ namespace LuaScript
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void SetValue(IVideoEffect model, PropertyInfo property, object value)
|
||||
private static void SetValue(IVideoEffect model, PropertyInfo property, object value, AviUtlParameterMapping parameter)
|
||||
{
|
||||
var type = property.PropertyType;
|
||||
|
||||
if (type == typeof(Animation))
|
||||
{
|
||||
if (property.GetValue(model) is Animation animation)
|
||||
animation.CopyFrom(new Animation(ToDouble(value)));
|
||||
animation.CopyFrom(new Animation(parameter.Transform(ToDouble(value))));
|
||||
return;
|
||||
}
|
||||
if (type == typeof(bool))
|
||||
@@ -240,7 +282,7 @@ namespace LuaScript
|
||||
}
|
||||
if (type == typeof(double) || type == typeof(float) || type == typeof(int) || type == typeof(long) || type == typeof(short))
|
||||
{
|
||||
property.SetValue(model, Convert.ChangeType(ToDouble(value), type, CultureInfo.InvariantCulture));
|
||||
property.SetValue(model, Convert.ChangeType(parameter.Transform(ToDouble(value)), type, CultureInfo.InvariantCulture));
|
||||
return;
|
||||
}
|
||||
if (type == typeof(string))
|
||||
|
||||
@@ -93,6 +93,32 @@
|
||||
العام لا يصاحبه إعلان نطاق/قيمة افتراضية، لذا تعامل مع نطاقات القيم داخل النص.
|
||||
وتبقى رؤوس AviUtl --track / --check / --color تعمل كما كانت.
|
||||
|
||||
توجد 4 منزلقات رقمية، ويُشار إليها عبر obj.slider0 إلى obj.slider3.
|
||||
القيم أعداد صحيحة ولا تحمل كسوراً عشرية.
|
||||
|
||||
Slider0 : منزلق صحيح (النطاق: 1 ~ 10)
|
||||
Slider1 : منزلق صحيح (النطاق: 0 ~ 100)
|
||||
Slider2 : منزلق صحيح (النطاق: 0 ~ 1000)
|
||||
Slider3 : منزلق صحيح (النطاق: -1000 ~ 1000)
|
||||
|
||||
تتوفر أيضاً معاملات نصية، ويُشار إلى كل قيمة بالأسماء التالية.
|
||||
|
||||
obj.text : نص حقل إدخال النص
|
||||
obj.font : اسم الخط من محدد الخطوط
|
||||
obj.dir : مسار محدد المجلدات
|
||||
obj.file_video : مسار ملف فيديو
|
||||
obj.file_audio : مسار ملف صوتي
|
||||
obj.file_image : مسار ملف صورة
|
||||
obj.file_project : مسار ملف مشروع
|
||||
obj.file_mp4 : مسار ملف MP4
|
||||
obj.file_exo : مسار ملف EXO
|
||||
obj.file_subtitle : مسار ملف ترجمة
|
||||
obj.file_shader : مسار ملف تظليل
|
||||
|
||||
※تظهر المنزلقات والمعاملات النصية في لوح التأثيرات تلقائياً عندما يشير إليها النص البرمجي.
|
||||
※يمكن تمرير مسار الملف إلى obj.load لتحميل صورة أو فيديو.
|
||||
※تتوفر هذه المعاملات في محركَي MoonSharp والمحرك الأصلي معاً.
|
||||
|
||||
|
||||
- المتغيرات العامة -
|
||||
|
||||
@@ -213,6 +239,18 @@
|
||||
obj.track2 : القيمة الحالية لـ Track2 في لوح التأثيرات [للقراءة فقط]
|
||||
obj.track3 : القيمة الحالية لـ Track3 في لوح التأثيرات [للقراءة فقط]
|
||||
|
||||
○ المنزلقات
|
||||
obj.slider0 : القيمة الحالية لـ Slider0 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider1 : القيمة الحالية لـ Slider1 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider2 : القيمة الحالية لـ Slider2 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider3 : القيمة الحالية لـ Slider3 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
|
||||
○ المعاملات النصية
|
||||
obj.text : نص حقل إدخال النص [للقراءة فقط]
|
||||
obj.font : اسم الخط من محدد الخطوط [للقراءة فقط]
|
||||
obj.dir : مسار محدد المجلدات [للقراءة فقط]
|
||||
obj.file_video ~ obj.file_shader : مسار كل محدد ملفات [للقراءة فقط]
|
||||
|
||||
○ الطبقة
|
||||
obj.layer : رقم الطبقة التي يوجد فيها الكائن [للقراءة فقط]
|
||||
* نفس قيمة المتغير العام layer.
|
||||
@@ -451,10 +489,54 @@
|
||||
الخيارات التي تؤثر على الرسم حالياً:
|
||||
"antialias" : 0 = أقرب جار، وإلا استيفاء خطّي
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : رقم وضع الدمج (obj.draw / obj.drawpoly). بنفس ترتيب
|
||||
القائمة المنسدلة "وضع الدمج" في لوحة الخصائص في YMM4 (يبدأ من 0):
|
||||
0=عادي,1=اكتمل الذوبان,2=أغمق,3=ضرب,4=حرق اللون,
|
||||
5=احتراق خطي,6=معالجة (أخفّ),7=شاشة,8=تراكب اللون,
|
||||
9=المزج الخطي (إضافة),10=إضافة,11=تراكب,12=ضوء ناعم,
|
||||
13=ضوء قوي,14=ضوء حيوي,15=الضوء الخطي,16=ضوء دبوس,
|
||||
17=مزج قوي,18=الفرق,19=استبعاد,20=طرح,21=القسمة,22=تدرج,
|
||||
23=التشبع,24=لون,25=السطوع,26=لون أفتح,27=خلفية,
|
||||
28=لون أغمق,29=مسح,30=القص حسب الخلفية,
|
||||
31=فقط الأجزاء غير المتراكبة,32=قناع عكس الألوان.
|
||||
القيم خارج النطاق أو غير الصالحة تُعامَل كـ 0 (عادي).
|
||||
"draw_state" : قيمة منطقية تحدد ما إذا كان هذا التأثير يُخرج صورة
|
||||
العمل. true تُخرج صورة العمل، وfalse تمرر الدخل كما هو. تُستخدم
|
||||
لإخراج صورة العمل دون obj.draw أو setpixel، أو لإيقاف الإخراج.
|
||||
تعمل في المحركين معاً.
|
||||
"drawtarget" : يبدّل وجهة رسم obj.draw / obj.drawpoly.
|
||||
"framebuffer" (الافتراضي) يركّب في مخزن الإطار. "tempbuffer"
|
||||
يركّب في مخزن العمل tmp مباشرة. في
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) تُحدد w, h حجم
|
||||
تهيئة مخزن tmp، وحذفهما يُبقيه كما هو. أعِد نتيجة tmp إلى صورة
|
||||
العمل عبر obj.copybuffer("obj", "tmp"). التركيب في tempbuffer
|
||||
عادي (source-over)، وblend يُطبَّق على الرسم في framebuffer.
|
||||
تعمل في المحركين معاً.
|
||||
|
||||
○ obj.pixeloption(name, value)
|
||||
يحفظ خياراً لعمليات البكسل كحالة.
|
||||
|
||||
○ obj.setanchor(name, count [, option, ..])
|
||||
يعرض نقاط الإرساء على المعاينة لضبط إحداثياتها بالسحب بالفأرة.
|
||||
تُحفَظ الإحداثيات المعدّلة مع المشروع.
|
||||
name : اسم متغير Lua الذي يستقبل الإحداثيات، كسلسلة نصية. يكون
|
||||
المتغير بالترتيب pos={x0,y0,x1,y1,…}، أو {x0,y0,z0,x1,y1,z1,…}
|
||||
مع "xyz". الإحداثيات بالنسبة إلى مركز الكائن.
|
||||
count : عدد نقاط الإرساء. حتى 32.
|
||||
option : تُذكَر كسلاسل نصية.
|
||||
"line" : يصل نقاط الإرساء بخطوط.
|
||||
"loop" : يصل نقاط الإرساء ويغلق الحلقة.
|
||||
"star" : يصل كل نقطة إرساء بمركز الكائن.
|
||||
"arm" : يصل مركز الكائن بكل نقطة إرساء بالترتيب.
|
||||
"xyz" : يعامل النقاط كإحداثيات ثلاثية الأبعاد. الافتراضي ثنائي.
|
||||
يعيد عدد نقاط الإرساء. يعمل في المحركين معاً.
|
||||
وضع شريط "track" غير مدعوم حالياً ويعيد 0.
|
||||
مثال:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -632,6 +714,41 @@
|
||||
و obj.getvalue، و obj.setoption / obj.getoption / obj.pixeloption.
|
||||
انظر "جدول obj - الدوال" للتفاصيل.
|
||||
|
||||
○ خريطة توافق AviUtl / AviUtl2 لـ obj.effect
|
||||
يَرجع obj.effect("اسم التأثير"، "اسم المعامل"، القيمة، ...) إلى خريطة
|
||||
التوافق أولًا. التأثيرات المُعلَنة بأسماء AviUtl / AviUtl2 تمر عبر تحويل
|
||||
المقياس/الإزاحة المُعلَن قبل الوصول إلى خصائص YMM4. الأسماء غير المُعلَنة في
|
||||
الخريطة تُحَلّ مباشرةً عبر اسم تأثير YMM4 أو كلمته المفتاحية، لذا تظل
|
||||
الاستدعاءات الحالية تعمل.
|
||||
بُنيت الخريطة كمعكوس لتصدير AviUtl الخاص بـ YMM4 نفسه (مخرجات .exo)، لذا
|
||||
تتطابق ذهابًا وإيابًا. يُختار المحرك الهدف عبر --!aviutl (الافتراضي) /
|
||||
--!aviutl2.
|
||||
أسماء التأثيرات المُعلَنة في الخريطة ومعاملاتها الرئيسية كما يلي:
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
يتوافق 色調補正 و 色ずれ مع تأثيرات إضافة المجتمع.
|
||||
|
||||
الميزات التالية خارج نطاق هذه الطبقة.
|
||||
النصوص التي تستدعيها لن تعمل كما هو متوقع.
|
||||
× تحميل الوحدات عبر require، والوصول العشوائي إلى الملفات مثل
|
||||
|
||||
@@ -97,6 +97,33 @@
|
||||
value ranges within the script. The AviUtl --track / --check / --color headers
|
||||
still work as before.
|
||||
|
||||
There are 4 numeric sliders, referenced as obj.slider0 through obj.slider3.
|
||||
The values are integers and do not hold decimals.
|
||||
|
||||
Slider0 : Integer slider (Range: 1 ~ 10)
|
||||
Slider1 : Integer slider (Range: 0 ~ 100)
|
||||
Slider2 : Integer slider (Range: 0 ~ 1000)
|
||||
Slider3 : Integer slider (Range: -1000 ~ 1000)
|
||||
|
||||
String parameters are also available, referenced by the following names.
|
||||
|
||||
obj.text : String from the text input field
|
||||
obj.font : Font name from the font selector
|
||||
obj.dir : Path from the folder selector
|
||||
obj.file_video : Path of a video file
|
||||
obj.file_audio : Path of an audio file
|
||||
obj.file_image : Path of an image file
|
||||
obj.file_project : Path of a project file
|
||||
obj.file_mp4 : Path of an MP4 file
|
||||
obj.file_exo : Path of an EXO file
|
||||
obj.file_subtitle : Path of a subtitle file
|
||||
obj.file_shader : Path of a shader file
|
||||
|
||||
* The sliders and string parameters appear in the effect panel automatically
|
||||
when the script references them.
|
||||
* A file path can be passed to obj.load to load an image or movie.
|
||||
* These parameters are available in both the MoonSharp and native engines.
|
||||
|
||||
|
||||
- Global Variables -
|
||||
|
||||
@@ -220,6 +247,18 @@
|
||||
obj.track2 : Current value of Track2 in the effect panel [ReadOnly]
|
||||
obj.track3 : Current value of Track3 in the effect panel [ReadOnly]
|
||||
|
||||
o Sliders
|
||||
obj.slider0 : Current value of Slider0 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider1 : Current value of Slider1 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider2 : Current value of Slider2 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider3 : Current value of Slider3 in the effect panel (integer) [ReadOnly]
|
||||
|
||||
o String parameters
|
||||
obj.text : String from the text input field [ReadOnly]
|
||||
obj.font : Font name from the font selector [ReadOnly]
|
||||
obj.dir : Path from the folder selector [ReadOnly]
|
||||
obj.file_video ~ obj.file_shader : Path from each file selector [ReadOnly]
|
||||
|
||||
o Layer
|
||||
obj.layer : Layer number where the object is placed [ReadOnly]
|
||||
* Same value as global variable layer.
|
||||
@@ -467,10 +506,58 @@
|
||||
Options that currently affect drawing:
|
||||
"antialias" : 0 = nearest neighbor, otherwise linear interpolation
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : blend mode number (obj.draw / obj.drawpoly). Same order
|
||||
(0-based) as YMM4's own "Blend mode" dropdown in the property
|
||||
panel: 0=Normal,1=Dissolve,2=Darker,3=Multiply,4=Color burn,
|
||||
5=Linear burn,6=Lighter,7=Screen,8=Color dodge,
|
||||
9=Linear dodge (Add),10=Add,11=Overlay,12=Soft light,
|
||||
13=Hard light,14=Vivid light,15=Linear light,16=Pin light,
|
||||
17=Hard mix,18=Difference,19=Exclution,20=Subtract,
|
||||
21=Division,22=Hue,23=Saturation,24=Color,25=Luminance,
|
||||
26=Lighter color,27=Behind,28=Darker color,29=Clear,
|
||||
30=Clipping by background,31=XOR,32=Color inversion mask.
|
||||
Out-of-range or invalid values are treated as 0 (Normal).
|
||||
"draw_state" : a boolean that decides whether this effect emits
|
||||
its working image. true outputs the working image; false passes
|
||||
the input through unchanged. Use it to emit the working image
|
||||
without obj.draw or setpixel, or to suppress the output. It works
|
||||
in both engines.
|
||||
"drawtarget" : switches the destination of obj.draw / obj.drawpoly.
|
||||
"framebuffer" (default) composites into the frame buffer.
|
||||
"tempbuffer" composites into the working tmp buffer in place. In
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) the w, h give the
|
||||
size to initialize the tmp buffer; omit them to keep it. Bring the
|
||||
tmp result back to the working image with
|
||||
obj.copybuffer("obj", "tmp"). Compositing into tempbuffer is
|
||||
normal (source-over); blend applies to framebuffer drawing. It
|
||||
works in both engines.
|
||||
|
||||
o obj.pixeloption(name, value)
|
||||
Stores an option for pixel operations as state.
|
||||
|
||||
o obj.setanchor(name, count [, option, ..])
|
||||
Shows anchor points on the preview so their coordinates can be
|
||||
adjusted by mouse dragging. The adjusted coordinates are saved with
|
||||
the project.
|
||||
name : the name of the Lua variable that receives the coordinates,
|
||||
given as a string. The variable is laid out as
|
||||
pos={x0,y0,x1,y1,…}, or {x0,y0,z0,x1,y1,z1,…} with "xyz".
|
||||
Coordinates are relative to the object center.
|
||||
count : the number of anchor points. Up to 32.
|
||||
option : enumerated as strings.
|
||||
"line" : connect the anchor points with lines.
|
||||
"loop" : connect the anchor points and close the loop.
|
||||
"star" : connect each anchor point to the object center.
|
||||
"arm" : connect the object center to each anchor point in order.
|
||||
"xyz" : treat the anchor points as 3D coordinates. 2D by default.
|
||||
Returns the number of anchor points. It works in both engines.
|
||||
The "track" trackbar mode is not supported yet and returns 0.
|
||||
Example:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -652,6 +739,42 @@
|
||||
obj.getvalue, and obj.setoption / obj.getoption / obj.pixeloption are
|
||||
supported. See "obj Table - Functions" for details.
|
||||
|
||||
o AviUtl / AviUtl2 compatibility map for obj.effect
|
||||
obj.effect("effect name", "parameter name", value, ...) first consults
|
||||
the compatibility map. Effects declared as AviUtl / AviUtl2 names pass
|
||||
through the declared scale/offset conversion before reaching the YMM4
|
||||
properties. Names not declared in the map are resolved directly by the
|
||||
YMM4 effect name or keyword, so existing calls keep working. The map is
|
||||
built as the inverse of YMM4's own AviUtl export (.exo output), so it
|
||||
round-trips exactly. The target engine is selected with --!aviutl
|
||||
(default) / --!aviutl2.
|
||||
The effect names declared in the map and their main parameters are as
|
||||
follows.
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 and 色ずれ correspond to community plugin effects.
|
||||
|
||||
The following are out of scope for this layer. Scripts that call them will not
|
||||
behave as intended.
|
||||
x Module loading via require, and arbitrary file access such as io /
|
||||
|
||||
@@ -97,6 +97,33 @@
|
||||
así que gestione los rangos dentro del script. Las cabeceras --track / --check /
|
||||
--color de AviUtl siguen funcionando como antes.
|
||||
|
||||
Hay 4 deslizadores numéricos, referenciados como obj.slider0 ~ obj.slider3.
|
||||
Los valores son enteros y no contienen decimales.
|
||||
|
||||
Slider0 : Deslizador entero (Rango: 1 ~ 10)
|
||||
Slider1 : Deslizador entero (Rango: 0 ~ 100)
|
||||
Slider2 : Deslizador entero (Rango: 0 ~ 1000)
|
||||
Slider3 : Deslizador entero (Rango: -1000 ~ 1000)
|
||||
|
||||
También hay parámetros de cadena, referenciados por los siguientes nombres.
|
||||
|
||||
obj.text : Cadena del campo de entrada de texto
|
||||
obj.font : Nombre de fuente del selector de fuentes
|
||||
obj.dir : Ruta del selector de carpetas
|
||||
obj.file_video : Ruta de un archivo de video
|
||||
obj.file_audio : Ruta de un archivo de audio
|
||||
obj.file_image : Ruta de un archivo de imagen
|
||||
obj.file_project : Ruta de un archivo de proyecto
|
||||
obj.file_mp4 : Ruta de un archivo MP4
|
||||
obj.file_exo : Ruta de un archivo EXO
|
||||
obj.file_subtitle : Ruta de un archivo de subtítulos
|
||||
obj.file_shader : Ruta de un archivo de sombreador
|
||||
|
||||
* Los deslizadores y los parámetros de cadena aparecen en el panel de efectos
|
||||
automáticamente cuando el script los referencia.
|
||||
* Una ruta de archivo puede pasarse a obj.load para cargar una imagen o un video.
|
||||
* Estos parámetros están disponibles en los motores MoonSharp y nativo.
|
||||
|
||||
|
||||
- Variables globales -
|
||||
|
||||
@@ -217,6 +244,18 @@
|
||||
obj.track2 : Valor actual de Track2 en el panel de efectos [Solo lectura]
|
||||
obj.track3 : Valor actual de Track3 en el panel de efectos [Solo lectura]
|
||||
|
||||
o Deslizadores
|
||||
obj.slider0 : Valor actual de Slider0 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider1 : Valor actual de Slider1 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider2 : Valor actual de Slider2 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider3 : Valor actual de Slider3 en el panel de efectos (entero) [Solo lectura]
|
||||
|
||||
o Parámetros de cadena
|
||||
obj.text : Cadena del campo de entrada de texto [Solo lectura]
|
||||
obj.font : Nombre de fuente del selector de fuentes [Solo lectura]
|
||||
obj.dir : Ruta del selector de carpetas [Solo lectura]
|
||||
obj.file_video ~ obj.file_shader : Ruta de cada selector de archivos [Solo lectura]
|
||||
|
||||
o Capa
|
||||
obj.layer : Número de capa donde se encuentra el objeto [Solo lectura]
|
||||
* Mismo valor que la variable global layer.
|
||||
@@ -466,10 +505,62 @@
|
||||
Opciones que afectan al dibujo actualmente:
|
||||
"antialias" : 0 = vecino más cercano, en otro caso interpolación
|
||||
lineal (obj.draw / obj.drawpoly).
|
||||
"blend" : número de modo de fusión (obj.draw / obj.drawpoly). El
|
||||
mismo orden (empezando en 0) que la lista desplegable "Modo de
|
||||
fusión" del panel de propiedades de YMM4:
|
||||
0=Normal,1=Síntesis de interpolación,2=Comparación (oscura),
|
||||
3=Multiplicar,4=Color de relleno,5=Burn-in (lineal),
|
||||
6=Comparación (clara),7=Pantalla,8=Color sin máscara,
|
||||
9=Sin máscara (lineal) - Aditivo,10=Adición,11=Superponer,
|
||||
12=Luz suave,13=Luz dura,14=Luz viva,15=Luz lineal,
|
||||
16=Pin Light,17=Mezcla dura,18=diferencia,19=Excluido,
|
||||
20=Sustracción,21=División,22=Tono,23=Saturación,24=Color,
|
||||
25=Luminosidad,26=Comparación de colores (claro),27=Fondo,
|
||||
28=Comparación de colores (oscuro),29=Supresión,
|
||||
30=Recorte en el fondo,31=Sólo partes no superpuestas,
|
||||
32=Máscara de inversión de color. Los valores fuera de rango
|
||||
o no válidos se tratan como 0 (Normal).
|
||||
"draw_state" : un booleano que decide si este efecto emite su
|
||||
imagen de trabajo. true emite la imagen de trabajo; false deja
|
||||
pasar la entrada sin cambios. Sirve para emitir la imagen de
|
||||
trabajo sin obj.draw ni setpixel, o para suprimir la salida.
|
||||
Funciona en ambos motores.
|
||||
"drawtarget" : cambia el destino de obj.draw / obj.drawpoly.
|
||||
"framebuffer" (por defecto) compone en el búfer de fotograma.
|
||||
"tempbuffer" compone en el búfer de trabajo tmp en el momento. En
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) los valores w, h
|
||||
dan el tamaño con que se inicializa el búfer tmp; omítelos para
|
||||
conservarlo. Recupera el resultado de tmp a la imagen de trabajo
|
||||
con obj.copybuffer("obj", "tmp"). La composición en tempbuffer es
|
||||
normal (source-over); blend se aplica al dibujo en framebuffer.
|
||||
Funciona en ambos motores.
|
||||
|
||||
o obj.pixeloption(nombre, valor)
|
||||
Guarda como estado una opción para las operaciones de píxeles.
|
||||
|
||||
o obj.setanchor(nombre, cantidad [, opción, ..])
|
||||
Muestra puntos de anclaje en la vista previa para ajustar sus
|
||||
coordenadas arrastrando con el ratón. Las coordenadas ajustadas se
|
||||
guardan con el proyecto.
|
||||
nombre : el nombre de la variable Lua que recibe las coordenadas,
|
||||
como cadena. La variable se dispone como pos={x0,y0,x1,y1,…}, o
|
||||
{x0,y0,z0,x1,y1,z1,…} con "xyz". Las coordenadas son relativas
|
||||
al centro del objeto.
|
||||
cantidad : el número de puntos de anclaje. Hasta 32.
|
||||
opción : se enumeran como cadenas.
|
||||
"line" : une los puntos de anclaje con líneas.
|
||||
"loop" : une los puntos de anclaje y cierra el bucle.
|
||||
"star" : une cada punto de anclaje con el centro del objeto.
|
||||
"arm" : une el centro del objeto con cada punto en orden.
|
||||
"xyz" : trata los puntos como coordenadas 3D. 2D por defecto.
|
||||
Devuelve el número de puntos de anclaje. Funciona en ambos motores.
|
||||
El modo de barra "track" aún no se admite y devuelve 0.
|
||||
Ejemplo:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -653,6 +744,44 @@
|
||||
obj.getvalue y obj.setoption / obj.getoption / obj.pixeloption.
|
||||
Consulte "Tabla obj - Funciones" para más detalles.
|
||||
|
||||
o Mapa de compatibilidad AviUtl / AviUtl2 para obj.effect
|
||||
obj.effect("nombre de efecto", "nombre de parámetro", valor, ...)
|
||||
consulta primero el mapa de compatibilidad. Los efectos declarados como
|
||||
nombres de AviUtl / AviUtl2 pasan por la conversión de
|
||||
escala/desplazamiento declarada antes de llegar a las propiedades de
|
||||
YMM4. Los nombres no declarados en el mapa se resuelven directamente por
|
||||
el nombre de efecto o la palabra clave de YMM4, por lo que las llamadas
|
||||
existentes siguen funcionando. El mapa se construye como la inversa de
|
||||
la propia exportación de AviUtl de YMM4 (salida .exo), por lo que es
|
||||
reversible de forma exacta. El motor de destino se selecciona con
|
||||
--!aviutl (predeterminado) / --!aviutl2.
|
||||
Los nombres de efecto declarados en el mapa y sus parámetros principales
|
||||
son los siguientes.
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 y 色ずれ corresponden a efectos del complemento de la comunidad.
|
||||
|
||||
Lo siguiente queda fuera del alcance de esta capa. Los scripts que lo llamen no
|
||||
se comportarán como se espera.
|
||||
x Carga de módulos mediante require y acceso arbitrario a archivos como
|
||||
|
||||
@@ -96,6 +96,33 @@
|
||||
rentang nilai di dalam skrip. Header --track / --check / --color AviUtl tetap
|
||||
berfungsi seperti sebelumnya.
|
||||
|
||||
Ada 4 slider numerik, direferensikan sebagai obj.slider0 hingga obj.slider3.
|
||||
Nilainya berupa bilangan bulat dan tidak memuat desimal.
|
||||
|
||||
Slider0 : Slider bilangan bulat (Rentang: 1 ~ 10)
|
||||
Slider1 : Slider bilangan bulat (Rentang: 0 ~ 100)
|
||||
Slider2 : Slider bilangan bulat (Rentang: 0 ~ 1000)
|
||||
Slider3 : Slider bilangan bulat (Rentang: -1000 ~ 1000)
|
||||
|
||||
Parameter string juga tersedia, direferensikan dengan nama berikut.
|
||||
|
||||
obj.text : String dari kolom input teks
|
||||
obj.font : Nama font dari pemilih font
|
||||
obj.dir : Path dari pemilih folder
|
||||
obj.file_video : Path file video
|
||||
obj.file_audio : Path file audio
|
||||
obj.file_image : Path file gambar
|
||||
obj.file_project : Path file proyek
|
||||
obj.file_mp4 : Path file MP4
|
||||
obj.file_exo : Path file EXO
|
||||
obj.file_subtitle : Path file subtitle
|
||||
obj.file_shader : Path file shader
|
||||
|
||||
* Slider dan parameter string muncul di panel efek secara otomatis saat skrip
|
||||
mereferensikannya.
|
||||
* Path file dapat diteruskan ke obj.load untuk memuat gambar atau video.
|
||||
* Parameter ini tersedia pada mesin MoonSharp maupun native.
|
||||
|
||||
|
||||
- Variabel Global -
|
||||
|
||||
@@ -216,6 +243,18 @@
|
||||
obj.track2 : Nilai saat ini Track2 di panel efek [Hanya Baca]
|
||||
obj.track3 : Nilai saat ini Track3 di panel efek [Hanya Baca]
|
||||
|
||||
o Slider
|
||||
obj.slider0 : Nilai saat ini Slider0 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider1 : Nilai saat ini Slider1 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider2 : Nilai saat ini Slider2 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider3 : Nilai saat ini Slider3 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
|
||||
o Parameter string
|
||||
obj.text : String dari kolom input teks [Hanya Baca]
|
||||
obj.font : Nama font dari pemilih font [Hanya Baca]
|
||||
obj.dir : Path dari pemilih folder [Hanya Baca]
|
||||
obj.file_video ~ obj.file_shader : Path dari setiap pemilih file [Hanya Baca]
|
||||
|
||||
o Layer
|
||||
obj.layer : Nomor layer tempat objek ditempatkan [Hanya Baca]
|
||||
* Nilai yang sama dengan variabel global layer.
|
||||
@@ -462,10 +501,61 @@
|
||||
Opsi yang saat ini memengaruhi penggambaran:
|
||||
"antialias" : 0 = tetangga terdekat, selain itu interpolasi linear
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : nomor mode blend (obj.draw / obj.drawpoly). Urutan yang
|
||||
sama (mulai dari 0) dengan dropdown "Mode blend" pada panel
|
||||
properti YMM4:
|
||||
0=Normal,1=Larut,2=Gelap,3=Multiply,4=Bakar warna,
|
||||
5=Bakar linier,6=Terang,7=Layar,8=Peleburan warna,
|
||||
9=Peleburan linier (tambah),10=Tambah,11=Overlay,
|
||||
12=Cahaya lembut,13=Cahaya keras,14=Cahaya hidup,
|
||||
15=Cahaya linier,16=Cahaya pin,17=Campuran keras,
|
||||
18=Perbedaan,19=Ekslklusi,20=Pengurangan,21=Divisi,22=Hue,
|
||||
23=Saturasi,24=Warna,25=Pencahayaan,26=Warna terang,
|
||||
27=Belakang,28=Warna gelap,29=Bersih,
|
||||
30=Potong dengan latar belakang,
|
||||
31=Hanya bagian yang tidak tumpang tindih,32=Mask inversi warna.
|
||||
Nilai di luar jangkauan atau tidak valid dianggap 0 (Normal).
|
||||
"draw_state" : boolean yang menentukan apakah efek ini
|
||||
mengeluarkan citra kerjanya. true mengeluarkan citra kerja;
|
||||
false meneruskan input apa adanya. Berguna untuk mengeluarkan
|
||||
citra kerja tanpa obj.draw atau setpixel, atau untuk menekan
|
||||
keluaran. Bekerja pada kedua mesin.
|
||||
"drawtarget" : mengganti tujuan gambar obj.draw / obj.drawpoly.
|
||||
"framebuffer" (bawaan) mengomposit ke frame buffer. "tempbuffer"
|
||||
mengomposit ke buffer kerja tmp secara langsung. Pada
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h), w, h adalah
|
||||
ukuran untuk menginisialisasi buffer tmp; hilangkan untuk
|
||||
mempertahankannya. Kembalikan hasil tmp ke citra kerja dengan
|
||||
obj.copybuffer("obj", "tmp"). Komposit ke tempbuffer bersifat
|
||||
normal (source-over); blend berlaku untuk gambar ke framebuffer.
|
||||
Bekerja pada kedua mesin.
|
||||
|
||||
o obj.pixeloption(name, value)
|
||||
Menyimpan opsi untuk operasi piksel sebagai status.
|
||||
|
||||
o obj.setanchor(name, count [, option, ..])
|
||||
Menampilkan titik jangkar pada pratinjau agar koordinatnya dapat
|
||||
disesuaikan dengan menyeret mouse. Koordinat yang disesuaikan
|
||||
disimpan bersama proyek.
|
||||
name : nama variabel Lua yang menerima koordinat, sebagai string.
|
||||
Variabel disusun sebagai pos={x0,y0,x1,y1,…}, atau
|
||||
{x0,y0,z0,x1,y1,z1,…} dengan "xyz". Koordinat relatif terhadap
|
||||
pusat objek.
|
||||
count : jumlah titik jangkar. Hingga 32.
|
||||
option : dicantumkan sebagai string.
|
||||
"line" : menghubungkan titik jangkar dengan garis.
|
||||
"loop" : menghubungkan titik jangkar dan menutup lingkaran.
|
||||
"star" : menghubungkan tiap titik jangkar ke pusat objek.
|
||||
"arm" : menghubungkan pusat objek ke tiap titik secara berurutan.
|
||||
"xyz" : memperlakukan titik sebagai koordinat 3D. Bawaan 2D.
|
||||
Mengembalikan jumlah titik jangkar. Bekerja pada kedua mesin.
|
||||
Mode bilah "track" belum didukung dan mengembalikan 0.
|
||||
Contoh:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -648,6 +738,42 @@
|
||||
obj.getvalue, serta obj.setoption / obj.getoption / obj.pixeloption
|
||||
didukung. Lihat "Tabel obj - Fungsi" untuk detailnya.
|
||||
|
||||
o Peta kompatibilitas AviUtl / AviUtl2 untuk obj.effect
|
||||
obj.effect("nama efek", "nama parameter", nilai, ...) pertama-tama
|
||||
merujuk peta kompatibilitas. Efek yang dideklarasikan sebagai nama
|
||||
AviUtl / AviUtl2 melewati konversi skala/offset yang dideklarasikan
|
||||
sebelum mencapai properti YMM4. Nama yang tidak dideklarasikan dalam peta
|
||||
diselesaikan langsung melalui nama efek atau kata kunci YMM4, sehingga
|
||||
pemanggilan yang sudah ada tetap berfungsi. Peta ini dibuat sebagai kebalikan dari ekspor AviUtl milik YMM4
|
||||
sendiri (keluaran .exo), sehingga konsisten secara bolak-balik. Mesin
|
||||
target dipilih dengan --!aviutl (bawaan) / --!aviutl2.
|
||||
Nama efek yang dideklarasikan dalam peta beserta parameter utamanya
|
||||
adalah sebagai berikut.
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 dan 色ずれ sesuai dengan efek plugin komunitas.
|
||||
|
||||
Berikut ini berada di luar cakupan lapisan ini. Skrip yang memanggilnya tidak
|
||||
akan berperilaku seperti yang diharapkan.
|
||||
x Pemuatan modul melalui require, dan akses berkas sembarang seperti
|
||||
|
||||
@@ -91,6 +91,33 @@
|
||||
この一般利用では範囲・既定値の宣言を伴わないため、値はスクリプト内で扱います。
|
||||
--track / --check / --color ヘッダによる宣言表示も従来どおり利用できます。
|
||||
|
||||
数値スライダーが 4 つあり、各値は obj.slider0 ~ obj.slider3 として参照できます。
|
||||
値は整数で、小数は扱いません。
|
||||
|
||||
Slider0 : 整数スライダー (範囲: 1 ~ 10)
|
||||
Slider1 : 整数スライダー (範囲: 0 ~ 100)
|
||||
Slider2 : 整数スライダー (範囲: 0 ~ 1000)
|
||||
Slider3 : 整数スライダー (範囲: -1000 ~ 1000)
|
||||
|
||||
文字列パラメータも利用でき、各値は以下の名前で参照できます。
|
||||
|
||||
obj.text : テキスト入力欄の文字列
|
||||
obj.font : フォント選択欄のフォント名
|
||||
obj.dir : フォルダ選択欄のパス
|
||||
obj.file_video : 動画ファイルのパス
|
||||
obj.file_audio : 音声ファイルのパス
|
||||
obj.file_image : 画像ファイルのパス
|
||||
obj.file_project : プロジェクトファイルのパス
|
||||
obj.file_mp4 : MP4 ファイルのパス
|
||||
obj.file_exo : EXO ファイルのパス
|
||||
obj.file_subtitle : 字幕ファイルのパス
|
||||
obj.file_shader : シェーダーファイルのパス
|
||||
|
||||
※スライダーと文字列パラメータは、スクリプト本体でそれらを参照すると
|
||||
自動的にエフェクトパネルへ表示されます。
|
||||
※ファイル選択のパスは obj.load へ渡して画像・動画の読み込みに使えます。
|
||||
※これらのパラメータは MoonSharp とネイティブのどちらのエンジンでも参照できます。
|
||||
|
||||
|
||||
- グローバル変数 -
|
||||
|
||||
@@ -214,6 +241,18 @@
|
||||
obj.track2 : エフェクトパネルの Track2 の現在値 [ReadOnly]
|
||||
obj.track3 : エフェクトパネルの Track3 の現在値 [ReadOnly]
|
||||
|
||||
○スライダー
|
||||
obj.slider0 : エフェクトパネルの Slider0 の現在値(整数) [ReadOnly]
|
||||
obj.slider1 : エフェクトパネルの Slider1 の現在値(整数) [ReadOnly]
|
||||
obj.slider2 : エフェクトパネルの Slider2 の現在値(整数) [ReadOnly]
|
||||
obj.slider3 : エフェクトパネルの Slider3 の現在値(整数) [ReadOnly]
|
||||
|
||||
○文字列パラメータ
|
||||
obj.text : テキスト入力欄の文字列 [ReadOnly]
|
||||
obj.font : フォント選択欄のフォント名 [ReadOnly]
|
||||
obj.dir : フォルダ選択欄のパス [ReadOnly]
|
||||
obj.file_video 〜 obj.file_shader : 各ファイル選択欄のパス [ReadOnly]
|
||||
|
||||
○レイヤー
|
||||
obj.layer : オブジェクトが配置されているレイヤー番号 [ReadOnly]
|
||||
※ グローバル変数 layer と同じ値です。
|
||||
@@ -451,10 +490,57 @@
|
||||
停止させません(getoption は設定値を返し、未設定は 0)。
|
||||
現在描画へ反映される項目:
|
||||
"antialias" : 0 で最近傍、それ以外で線形補間(obj.draw/drawpoly)。
|
||||
"blend" : obj.draw / obj.drawpoly の合成モードを番号で指定します。
|
||||
YMM4 のプロパティパネルにある「合成モード」のドロップダウンと
|
||||
並び順が同じで、番号は 0 から始まります。
|
||||
0=通常,1=ディザ合成,2=比較(暗),3=乗算,4=焼き込みカラー,
|
||||
5=焼き込み(リニア),6=比較(明),7=スクリーン,8=覆い焼きカラー,
|
||||
9=覆い焼き(リニア) - 加算,10=加算,11=オーバーレイ,
|
||||
12=ソフトライト,13=ハードライト,14=ビビッドライト,15=リニアライト,
|
||||
16=ピンライト,17=ハードミックス,18=差分,19=除外,20=減算,21=除算,
|
||||
22=色相,23=彩度,24=カラー,25=輝度,26=カラー比較(明),27=背景,
|
||||
28=カラー比較(暗),29=削除,30=背景でクリッピング,
|
||||
31=重ならない部分のみ,32=色反転マスク。
|
||||
範囲外の値や数値以外を指定した場合は通常モードになります。
|
||||
"draw_state" : このエフェクトが作業画像を出力するかどうかを
|
||||
真偽値で決めます。true で作業画像を出力し、false で入力を
|
||||
そのまま通します。obj.draw や setpixel を使わずに作業画像を
|
||||
そのまま出力させたいときや、逆に出力を止めたいときに使います。
|
||||
両エンジンで動きます。
|
||||
"drawtarget" : obj.draw / obj.drawpoly の描画先を切り替えます。
|
||||
"framebuffer"(既定)ではフレームバッファへ合成します。
|
||||
"tempbuffer" では作業用の tmp バッファへその場で合成します。
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) の w, h は
|
||||
tmp バッファを初期化するサイズで、省略すると初期化しません。
|
||||
tmp へ描いた結果は obj.copybuffer("obj", "tmp") で作業画像へ
|
||||
戻せます。tempbuffer への合成は通常(ソースオーバー)で、blend は
|
||||
framebuffer への描画に適用されます。両エンジンで動きます。
|
||||
|
||||
○obj.pixeloption(名前, 値)
|
||||
ピクセル操作のオプションを状態として保持します。
|
||||
|
||||
○obj.setanchor(名前, 個数 [, オプション, ..])
|
||||
アンカーポイントをプレビュー上に表示し、マウスドラッグで座標を
|
||||
調整できるようにします。調整した座標はプロジェクトへ保存されます。
|
||||
名前 : 座標を格納する Lua 変数の名前を文字列で指定します。
|
||||
変数は pos={x0,y0,x1,y1,…} の並びで、xyz 指定時は
|
||||
{x0,y0,z0,x1,y1,z1,…} になります。座標はオブジェクトの
|
||||
中心が原点です。
|
||||
個数 : アンカーポイントの数を指定します。最大 32 個です。
|
||||
オプション : 文字列で列挙できます。
|
||||
"line" : アンカーポイントを線で結びます。
|
||||
"loop" : アンカーポイントを線で結び一周させます。
|
||||
"star" : 各アンカーポイントとオブジェクトの中心を線で結びます。
|
||||
"arm" : オブジェクトの中心から各アンカーポイントへ順に線で結びます。
|
||||
"xyz" : アンカーポイントを 3D 座標で扱います。既定は 2D です。
|
||||
戻り値は設置したアンカーポイントの数です。両エンジンで動きます。
|
||||
名前に "track" を指定するトラックバー連携は現在未対応で、0 を返します。
|
||||
例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 テーブル -
|
||||
@@ -634,6 +720,41 @@
|
||||
obj.getoption / obj.pixeloption に対応します。詳細は「obj テーブル -
|
||||
関数」を参照してください。
|
||||
|
||||
○obj.effect の AviUtl/AviUtl2 互換マップ
|
||||
obj.effect("エフェクト名", "パラメータ名", 値, …) はまず互換マップを
|
||||
参照します。AviUtl/AviUtl2 の名前として宣言したエフェクトは、値がマップに
|
||||
定義した倍率とオフセットの変換を経て YMM4 のプロパティへ反映します。互換
|
||||
マップに宣言が無い名前は、YMM4 のエフェクト名やキーワードでそのまま解決
|
||||
するため、既存の呼び出しはそのまま動きます。この互換マップは、YMM4 自身が AviUtl の
|
||||
.exo へ書き出す変換を逆向きにたどって作っているため、往復しても結果が
|
||||
一致します。対象のエンジンは指定子 --!aviutl または --!aviutl2 で
|
||||
切り替えます。指定子を書かないときは --!aviutl として扱います。
|
||||
マップに宣言したエフェクト名と主なパラメータは次のとおりです。
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: パラメータなし
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 と 色ずれ はコミュニティプラグインのエフェクトに対応します。
|
||||
|
||||
次の機能はこの互換層では対象外です。
|
||||
これらを呼び出すスクリプトは意図どおりには動作しません。
|
||||
×require によるモジュール読み込み、io / dofile などの任意ファイル
|
||||
|
||||
@@ -91,6 +91,32 @@
|
||||
선언을 동반하지 않으므로 값의 범위는 스크립트 내에서 처리하세요. AviUtl의
|
||||
--track / --check / --color 헤더 선언 표시도 기존과 동일하게 사용할 수 있습니다.
|
||||
|
||||
숫자 슬라이더가 4개 있으며, 각 값은 obj.slider0 ~ obj.slider3으로 참조할 수 있습니다.
|
||||
값은 정수이며 소수는 다루지 않습니다.
|
||||
|
||||
Slider0 : 정수 슬라이더 (범위: 1 ~ 10)
|
||||
Slider1 : 정수 슬라이더 (범위: 0 ~ 100)
|
||||
Slider2 : 정수 슬라이더 (범위: 0 ~ 1000)
|
||||
Slider3 : 정수 슬라이더 (범위: -1000 ~ 1000)
|
||||
|
||||
문자열 파라미터도 사용할 수 있으며, 각 값은 다음 이름으로 참조합니다.
|
||||
|
||||
obj.text : 텍스트 입력란의 문자열
|
||||
obj.font : 글꼴 선택란의 글꼴 이름
|
||||
obj.dir : 폴더 선택란의 경로
|
||||
obj.file_video : 동영상 파일의 경로
|
||||
obj.file_audio : 음성 파일의 경로
|
||||
obj.file_image : 이미지 파일의 경로
|
||||
obj.file_project : 프로젝트 파일의 경로
|
||||
obj.file_mp4 : MP4 파일의 경로
|
||||
obj.file_exo : EXO 파일의 경로
|
||||
obj.file_subtitle : 자막 파일의 경로
|
||||
obj.file_shader : 셰이더 파일의 경로
|
||||
|
||||
※슬라이더와 문자열 파라미터는 스크립트 본문에서 참조하면 이펙트 패널에 자동으로 표시됩니다.
|
||||
※파일 선택 경로는 obj.load에 전달해 이미지・동영상을 불러오는 데 사용할 수 있습니다.
|
||||
※이 파라미터들은 MoonSharp과 네이티브 두 엔진에서 모두 참조할 수 있습니다.
|
||||
|
||||
|
||||
- 전역 변수 -
|
||||
|
||||
@@ -211,6 +237,18 @@
|
||||
obj.track2 : 이펙트 패널의 Track2 현재값 [읽기 전용]
|
||||
obj.track3 : 이펙트 패널의 Track3 현재값 [읽기 전용]
|
||||
|
||||
○ 슬라이더
|
||||
obj.slider0 : 이펙트 패널의 Slider0 현재값(정수) [읽기 전용]
|
||||
obj.slider1 : 이펙트 패널의 Slider1 현재값(정수) [읽기 전용]
|
||||
obj.slider2 : 이펙트 패널의 Slider2 현재값(정수) [읽기 전용]
|
||||
obj.slider3 : 이펙트 패널의 Slider3 현재값(정수) [읽기 전용]
|
||||
|
||||
○ 문자열 파라미터
|
||||
obj.text : 텍스트 입력란의 문자열 [읽기 전용]
|
||||
obj.font : 글꼴 선택란의 글꼴 이름 [읽기 전용]
|
||||
obj.dir : 폴더 선택란의 경로 [읽기 전용]
|
||||
obj.file_video ~ obj.file_shader : 각 파일 선택란의 경로 [읽기 전용]
|
||||
|
||||
○ 레이어
|
||||
obj.layer : 오브젝트가 배치된 레이어 번호 [읽기 전용]
|
||||
※ 전역 변수 layer와 동일한 값입니다.
|
||||
@@ -446,10 +484,56 @@
|
||||
스크립트를 중단시키지 않습니다(getoption은 설정값을 반환, 미설정은 0).
|
||||
현재 그리기에 반영되는 항목:
|
||||
"antialias" : 0이면 최근접, 그 외는 선형 보간(obj.draw / obj.drawpoly).
|
||||
"blend" : 합성 모드 번호(obj.draw / obj.drawpoly). YMM4 속성
|
||||
패널의 "합성 모드" 드롭다운과 동일한 순서(0부터 시작):
|
||||
0=보통,1=디졸브,2=비교(어두움),3=곱하기,4=색상번,
|
||||
5=구워내기(선형),6=비교(밝음),7=화면,8=색상 닷지,
|
||||
9=선형 닷지 ‐ 가산,10=가산,11=오버레이,12=소프트 라이트,
|
||||
13=하드 라이트,14=선명한 라이트,15=리니어 라이트,16=핀 라이트,
|
||||
17=하드 믹스,18=차분,19=제외,20=감산,21=디비전,22=색조,
|
||||
23=채도,24=컬러,25=밝기,26=색상 비교(밝음),27=배경,
|
||||
28=색상 비교(어두운),29=삭제,30=배경에서 클리핑,
|
||||
31=겹치지 않는 부분만,32=색상 반전 마스크.
|
||||
범위를 벗어나거나 잘못된 값은 0(보통)으로 처리합니다.
|
||||
"draw_state" : 이 이펙트가 작업 이미지를 출력할지를 불리언으로
|
||||
정합니다. true는 작업 이미지를 출력하고, false는 입력을 그대로
|
||||
통과시킵니다. obj.draw나 setpixel을 쓰지 않고 작업 이미지를
|
||||
출력하거나, 반대로 출력을 막을 때 사용합니다. 두 엔진 모두에서
|
||||
동작합니다.
|
||||
"drawtarget" : obj.draw / obj.drawpoly의 그리기 대상을 바꿉니다.
|
||||
"framebuffer"(기본)는 프레임 버퍼에 합성합니다. "tempbuffer"는
|
||||
작업용 tmp 버퍼에 즉시 합성합니다.
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h)의 w, h는 tmp
|
||||
버퍼를 초기화하는 크기이며, 생략하면 초기화하지 않습니다. tmp에
|
||||
그린 결과는 obj.copybuffer("obj", "tmp")로 작업 이미지에 되돌릴
|
||||
수 있습니다. tempbuffer로의 합성은 보통(소스 오버)이며, blend는
|
||||
framebuffer 그리기에 적용됩니다. 두 엔진 모두에서 동작합니다.
|
||||
|
||||
○ obj.pixeloption(이름, 값)
|
||||
픽셀 조작 옵션을 상태로 보존합니다.
|
||||
|
||||
○ obj.setanchor(이름, 개수 [, 옵션, ..])
|
||||
프리뷰에 앵커 포인트를 표시하고 마우스 드래그로 좌표를 조정할 수
|
||||
있게 합니다. 조정한 좌표는 프로젝트에 저장됩니다.
|
||||
이름 : 좌표를 받을 Lua 변수 이름을 문자열로 지정합니다. 변수는
|
||||
pos={x0,y0,x1,y1,…} 배열이며, "xyz" 지정 시
|
||||
{x0,y0,z0,x1,y1,z1,…}가 됩니다. 좌표는 오브젝트 중심이
|
||||
원점입니다.
|
||||
개수 : 앵커 포인트 수를 지정합니다. 최대 32개입니다.
|
||||
옵션 : 문자열로 열거할 수 있습니다.
|
||||
"line" : 앵커 포인트를 선으로 잇습니다.
|
||||
"loop" : 앵커 포인트를 선으로 잇고 한 바퀴 닫습니다.
|
||||
"star" : 각 앵커 포인트를 오브젝트 중심과 선으로 잇습니다.
|
||||
"arm" : 오브젝트 중심에서 각 앵커 포인트로 차례로 잇습니다.
|
||||
"xyz" : 앵커 포인트를 3D 좌표로 다룹니다. 기본은 2D입니다.
|
||||
설치한 앵커 포인트 수를 반환합니다. 두 엔진 모두에서 동작합니다.
|
||||
이름에 "track"을 지정하는 트랙바 연동은 현재 미지원이며 0을 반환합니다.
|
||||
예:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 테이블 -
|
||||
@@ -629,6 +713,41 @@
|
||||
obj.getoption / obj.pixeloption을 지원합니다. 자세한 내용은
|
||||
"obj 테이블 - 함수"를 참조하세요.
|
||||
|
||||
○ obj.effect의 AviUtl / AviUtl2 호환 맵
|
||||
obj.effect("이펙트 이름", "파라미터 이름", 값, ...)은 먼저 호환 맵을
|
||||
참조합니다. AviUtl / AviUtl2의 이름으로 선언된 이펙트는 값이 선언된
|
||||
배율·오프셋 변환을 거쳐 YMM4의 속성에 반영됩니다. 맵에 선언되지 않은
|
||||
이름은 YMM4의 이펙트 이름이나 키워드로 그대로 해석되므로 기존 호출도
|
||||
그대로 동작합니다.
|
||||
이 맵은 YMM4 자체의 AviUtl 내보내기(.exo 출력)의 역으로 만들어졌기 때문에
|
||||
왕복해도 일치합니다. 대상 엔진은 --!aviutl(기본) / --!aviutl2로
|
||||
전환합니다.
|
||||
맵에 선언된 이펙트 이름과 주요 파라미터는 다음과 같습니다.
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 와 色ずれ 는 커뮤니티 플러그인의 이펙트에 대응합니다.
|
||||
|
||||
다음 기능은 이 호환 계층의 범위 밖입니다.
|
||||
이를 호출하는 스크립트는 의도대로 동작하지 않습니다.
|
||||
× require에 의한 모듈 로드 및 io / dofile 등의 임의 파일 접근
|
||||
|
||||
@@ -89,6 +89,32 @@
|
||||
自动显示在特效面板中(轨道条始终显示)。该通用用法不带范围・默认值声明,
|
||||
因此请在脚本内处理取值范围。AviUtl 的 --track / --check / --color 头声明显示仍可照常使用。
|
||||
|
||||
共有 4 个数值滑块,各值可通过 obj.slider0 ~ obj.slider3 引用。
|
||||
取值为整数,不处理小数。
|
||||
|
||||
Slider0 : 整数滑块 (范围: 1 ~ 10)
|
||||
Slider1 : 整数滑块 (范围: 0 ~ 100)
|
||||
Slider2 : 整数滑块 (范围: 0 ~ 1000)
|
||||
Slider3 : 整数滑块 (范围: -1000 ~ 1000)
|
||||
|
||||
还可使用字符串参数,各值通过以下名称引用。
|
||||
|
||||
obj.text : 文本输入框的字符串
|
||||
obj.font : 字体选择框的字体名
|
||||
obj.dir : 文件夹选择框的路径
|
||||
obj.file_video : 视频文件的路径
|
||||
obj.file_audio : 音频文件的路径
|
||||
obj.file_image : 图像文件的路径
|
||||
obj.file_project : 项目文件的路径
|
||||
obj.file_mp4 : MP4 文件的路径
|
||||
obj.file_exo : EXO 文件的路径
|
||||
obj.file_subtitle : 字幕文件的路径
|
||||
obj.file_shader : 着色器文件的路径
|
||||
|
||||
※滑块与字符串参数在脚本本体引用它们时会自动显示在特效面板中。
|
||||
※文件选择的路径可传给 obj.load 用于加载图像・视频。
|
||||
※这些参数在 MoonSharp 与原生两种引擎中均可引用。
|
||||
|
||||
|
||||
- 全局变量 -
|
||||
|
||||
@@ -209,6 +235,18 @@
|
||||
obj.track2 : 特效面板 Track2 的当前值 [只读]
|
||||
obj.track3 : 特效面板 Track3 的当前值 [只读]
|
||||
|
||||
○ 滑块
|
||||
obj.slider0 : 特效面板 Slider0 的当前值(整数) [只读]
|
||||
obj.slider1 : 特效面板 Slider1 的当前值(整数) [只读]
|
||||
obj.slider2 : 特效面板 Slider2 的当前值(整数) [只读]
|
||||
obj.slider3 : 特效面板 Slider3 的当前值(整数) [只读]
|
||||
|
||||
○ 字符串参数
|
||||
obj.text : 文本输入框的字符串 [只读]
|
||||
obj.font : 字体选择框的字体名 [只读]
|
||||
obj.dir : 文件夹选择框的路径 [只读]
|
||||
obj.file_video ~ obj.file_shader : 各文件选择框的路径 [只读]
|
||||
|
||||
○ 图层
|
||||
obj.layer : 对象所在的图层编号 [只读]
|
||||
* 与全局变量 layer 的值相同。
|
||||
@@ -439,10 +477,49 @@
|
||||
(getoption 返回设置值,未设置为 0)。
|
||||
当前会反映到绘制的项目:
|
||||
"antialias" : 0 为最近邻,其它为线性插值(obj.draw / obj.drawpoly)。
|
||||
"blend" : 合成模式编号(obj.draw / obj.drawpoly)。与 YMM4 属性
|
||||
面板中「合成模式」下拉列表相同的顺序(从 0 开始):
|
||||
0=普通,1=溶解,2=对比(暗),3=相乘,4=颜色加深,5=线性加深,
|
||||
6=对比(明),7=画面,8=颜色减淡,9=线性减淡 (相加),10=相加,
|
||||
11=覆盖,12=柔光,13=强光,14=亮光,15=明暗,16=点光,17=实色混合,
|
||||
18=反差,19=排除,20=相减,21=相除,22=色相,23=饱和度,24=颜色,
|
||||
25=亮度,26=颜色对比(明),27=背景,28=颜色对比(暗),29=清除,
|
||||
30=按背景裁剪,31=异或,32=颜色反转遮罩。超出范围或无效的值
|
||||
将按 0(普通)处理。
|
||||
"draw_state" : 用布尔值决定该效果是否输出工作图像。true 输出
|
||||
工作图像,false 则原样传递输入。可用于不使用 obj.draw 或
|
||||
setpixel 也输出工作图像,或反过来抑制输出。两个引擎都可用。
|
||||
"drawtarget" : 切换 obj.draw / obj.drawpoly 的绘制目标。
|
||||
"framebuffer"(默认)合成到帧缓冲。"tempbuffer" 则就地合成到
|
||||
工作用 tmp 缓冲。obj.setoption("drawtarget", "tempbuffer", w, h)
|
||||
中的 w, h 是初始化 tmp 缓冲的尺寸,省略则不初始化。画到 tmp 的
|
||||
结果可用 obj.copybuffer("obj", "tmp") 取回工作图像。合成到
|
||||
tempbuffer 使用普通(源覆盖),blend 应用于 framebuffer 的绘制。
|
||||
两个引擎都可用。
|
||||
|
||||
○ obj.pixeloption(名称, 值)
|
||||
将像素操作的选项作为状态保存。
|
||||
|
||||
○ obj.setanchor(名称, 个数 [, 选项, ..])
|
||||
在预览上显示锚点,可用鼠标拖动调整坐标。调整后的坐标会随工程保存。
|
||||
名称 : 以字符串指定接收坐标的 Lua 变量名。变量排列为
|
||||
pos={x0,y0,x1,y1,…},指定 "xyz" 时为 {x0,y0,z0,x1,y1,z1,…}。
|
||||
坐标以对象中心为原点。
|
||||
个数 : 指定锚点数量。最多 32 个。
|
||||
选项 : 可用字符串列举。
|
||||
"line" : 用线连接锚点。
|
||||
"loop" : 用线连接锚点并闭合一圈。
|
||||
"star" : 将每个锚点与对象中心用线连接。
|
||||
"arm" : 从对象中心依次连接到各锚点。
|
||||
"xyz" : 以 3D 坐标处理锚点。默认是 2D。
|
||||
返回设置的锚点数量。两个引擎都可用。
|
||||
名称指定 "track" 的轨道条联动暂不支持,返回 0。
|
||||
示例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
@@ -616,6 +693,39 @@
|
||||
obj.effect、obj.getvalue 以及 obj.setoption / obj.getoption /
|
||||
obj.pixeloption。详情请参阅“obj 表 - 函数”。
|
||||
|
||||
○ obj.effect 的 AviUtl / AviUtl2 兼容映射
|
||||
obj.effect("效果名", "参数名", 值, ...) 会先查阅兼容映射。
|
||||
以 AviUtl / AviUtl2 名称声明的效果,数值会经过声明的倍率/偏移转换后再写入
|
||||
YMM4 的属性。映射中未声明的名称则按 YMM4 的效果名或关键字直接解析,
|
||||
因此既有调用仍可正常使用。该映射是按 YMM4 自身的 AviUtl 导出
|
||||
(.exo 输出) 的逆向构建的,因此往返一致。目标引擎通过 --!aviutl(默认) /
|
||||
--!aviutl2 切换。
|
||||
映射中声明的效果名及其主要参数如下。
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 与 色ずれ 对应社区插件的效果。
|
||||
|
||||
以下功能不在此兼容层的范围内。
|
||||
调用它们的脚本不会按预期运行。
|
||||
× 通过 require 加载模块,以及 io / dofile 等任意文件访问
|
||||
|
||||
@@ -89,6 +89,32 @@
|
||||
自動顯示於特效面板中(軌道條始終顯示)。此通用用法不帶範圍・預設值宣告,
|
||||
因此請在腳本內處理取值範圍。AviUtl 的 --track / --check / --color 標頭宣告顯示仍可照常使用。
|
||||
|
||||
共有 4 個數值滑桿,各值可透過 obj.slider0 ~ obj.slider3 參照。
|
||||
取值為整數,不處理小數。
|
||||
|
||||
Slider0 : 整數滑桿 (範圍: 1 ~ 10)
|
||||
Slider1 : 整數滑桿 (範圍: 0 ~ 100)
|
||||
Slider2 : 整數滑桿 (範圍: 0 ~ 1000)
|
||||
Slider3 : 整數滑桿 (範圍: -1000 ~ 1000)
|
||||
|
||||
亦可使用字串參數,各值透過以下名稱參照。
|
||||
|
||||
obj.text : 文字輸入框的字串
|
||||
obj.font : 字型選擇框的字型名
|
||||
obj.dir : 資料夾選擇框的路徑
|
||||
obj.file_video : 影片檔案的路徑
|
||||
obj.file_audio : 音訊檔案的路徑
|
||||
obj.file_image : 圖片檔案的路徑
|
||||
obj.file_project : 專案檔案的路徑
|
||||
obj.file_mp4 : MP4 檔案的路徑
|
||||
obj.file_exo : EXO 檔案的路徑
|
||||
obj.file_subtitle : 字幕檔案的路徑
|
||||
obj.file_shader : 著色器檔案的路徑
|
||||
|
||||
※滑桿與字串參數在腳本本體參照它們時會自動顯示於特效面板中。
|
||||
※檔案選擇的路徑可傳給 obj.load 用於載入圖片・影片。
|
||||
※這些參數在 MoonSharp 與原生兩種引擎中皆可參照。
|
||||
|
||||
|
||||
- 全域變數 -
|
||||
|
||||
@@ -209,6 +235,18 @@
|
||||
obj.track2 : 特效面板 Track2 的當前值 [唯讀]
|
||||
obj.track3 : 特效面板 Track3 的當前值 [唯讀]
|
||||
|
||||
○ 滑桿
|
||||
obj.slider0 : 特效面板 Slider0 的當前值(整數) [唯讀]
|
||||
obj.slider1 : 特效面板 Slider1 的當前值(整數) [唯讀]
|
||||
obj.slider2 : 特效面板 Slider2 的當前值(整數) [唯讀]
|
||||
obj.slider3 : 特效面板 Slider3 的當前值(整數) [唯讀]
|
||||
|
||||
○ 字串參數
|
||||
obj.text : 文字輸入框的字串 [唯讀]
|
||||
obj.font : 字型選擇框的字型名 [唯讀]
|
||||
obj.dir : 資料夾選擇框的路徑 [唯讀]
|
||||
obj.file_video ~ obj.file_shader : 各檔案選擇框的路徑 [唯讀]
|
||||
|
||||
○ 圖層
|
||||
obj.layer : 物件所在的圖層編號 [唯讀]
|
||||
* 與全域變數 layer 的值相同。
|
||||
@@ -439,10 +477,50 @@
|
||||
(getoption 回傳設定值,未設定為 0)。
|
||||
目前會反映到繪製的項目:
|
||||
"antialias" : 0 為最近鄰,其它為線性內插(obj.draw / obj.drawpoly)。
|
||||
"blend" : 合成模式編號(obj.draw / obj.drawpoly)。與 YMM4 屬性
|
||||
面板中「合成模式」下拉選單相同的順序(從 0 開始):
|
||||
0=一般,1=Dissolve,2=比較(暗),3=相乘,4=Color burn,5=陰影,
|
||||
6=比較(亮),7=畫面,8=Color dodge,9=Linear dodge (Add),
|
||||
10=相加,11=覆蓋,12=Soft light,13=Hard light,14=Vivid light,
|
||||
15=明暗,16=Pin light,17=Hard mix,18=差異,19=Exclution,
|
||||
20=相減,21=Division,22=Hue,23=Saturation,24=色,25=亮度,
|
||||
26=Lighter color,27=Behind,28=Darker color,29=Clear,
|
||||
30=Clipping by background,31=XOR,32=Color inversion mask。
|
||||
超出範圍或無效的值將視為 0(一般)。
|
||||
"draw_state" : 以布林值決定此效果是否輸出工作影像。true 輸出
|
||||
工作影像,false 則原樣傳遞輸入。可用於不使用 obj.draw 或
|
||||
setpixel 也輸出工作影像,或反過來抑制輸出。兩個引擎都可用。
|
||||
"drawtarget" : 切換 obj.draw / obj.drawpoly 的繪製目標。
|
||||
"framebuffer"(預設)合成到影格緩衝。"tempbuffer" 則就地合成到
|
||||
工作用 tmp 緩衝。obj.setoption("drawtarget", "tempbuffer", w, h)
|
||||
中的 w, h 是初始化 tmp 緩衝的尺寸,省略則不初始化。畫到 tmp 的
|
||||
結果可用 obj.copybuffer("obj", "tmp") 取回工作影像。合成到
|
||||
tempbuffer 使用一般(來源覆蓋),blend 套用於 framebuffer 的繪製。
|
||||
兩個引擎都可用。
|
||||
|
||||
○ obj.pixeloption(名稱, 值)
|
||||
將像素操作的選項作為狀態保存。
|
||||
|
||||
○ obj.setanchor(名稱, 個數 [, 選項, ..])
|
||||
在預覽上顯示錨點,可用滑鼠拖曳調整座標。調整後的座標會隨專案保存。
|
||||
名稱 : 以字串指定接收座標的 Lua 變數名。變數排列為
|
||||
pos={x0,y0,x1,y1,…},指定 "xyz" 時為 {x0,y0,z0,x1,y1,z1,…}。
|
||||
座標以物件中心為原點。
|
||||
個數 : 指定錨點數量。最多 32 個。
|
||||
選項 : 可用字串列舉。
|
||||
"line" : 用線連接錨點。
|
||||
"loop" : 用線連接錨點並閉合一圈。
|
||||
"star" : 將每個錨點與物件中心用線連接。
|
||||
"arm" : 從物件中心依序連接到各錨點。
|
||||
"xyz" : 以 3D 座標處理錨點。預設是 2D。
|
||||
回傳設置的錨點數量。兩個引擎都可用。
|
||||
名稱指定 "track" 的軌道條連動暫不支援,回傳 0。
|
||||
範例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
@@ -616,6 +694,39 @@
|
||||
obj.effect、obj.getvalue 以及 obj.setoption / obj.getoption /
|
||||
obj.pixeloption。詳情請參閱「obj 表 - 函式」。
|
||||
|
||||
○ obj.effect 的 AviUtl / AviUtl2 相容對應表
|
||||
obj.effect("效果名", "參數名", 值, ...) 會先查閱相容對應表。
|
||||
以 AviUtl / AviUtl2 名稱宣告的效果,數值會經過宣告的倍率/位移轉換後再寫入
|
||||
YMM4 的屬性。對應表中未宣告的名稱則依 YMM4 的效果名或關鍵字直接解析,
|
||||
因此既有呼叫仍可正常使用。此對應表是依 YMM4 自身的 AviUtl 匯出
|
||||
(.exo 輸出) 的逆向建構的,因此往返一致。目標引擎透過 --!aviutl(預設) /
|
||||
--!aviutl2 切換。
|
||||
對應表中宣告的效果名及其主要參數如下。
|
||||
ぼかし: 範囲, サイズ固定
|
||||
境界ぼかし: 範囲
|
||||
方向ブラー: 範囲, 角度, サイズ固定
|
||||
放射ブラー: 範囲, X, Y, サイズを固定
|
||||
閃光: 範囲, X, Y, サイズを固定
|
||||
クロマキー: 色相範囲, 境界補正
|
||||
クリッピング: 上, 下, 左, 右, 中心の位置を変更
|
||||
斜めクリッピング: 中心X, 中心Y, 角度, ぼかし, 幅
|
||||
領域拡張: 上, 下, 左, 右
|
||||
座標: X, Y, Z
|
||||
回転: X, Y, Z
|
||||
リサイズ: 拡大率, X, Y, 補間なし
|
||||
画像ループ: 横回数, 縦回数
|
||||
極座標変換: 中心幅, 渦巻
|
||||
グラデーション: 強さ, 中心X, 中心Y, 角度, 幅
|
||||
単色化: 強さ, 輝度を保持する
|
||||
縁取り: サイズ, ぼかし
|
||||
反転: -
|
||||
モザイク: サイズ
|
||||
ディスプレイスメントマップ: ぼかし
|
||||
動画ファイル合成: X, Y, 拡大率
|
||||
色調補正: 明るさ, コントラスト, 色相, 輝度, 彩度
|
||||
色ずれ: ずれ幅, 角度, 強さ
|
||||
色調補正 與 色ずれ 對應社群外掛的效果。
|
||||
|
||||
以下功能不在此相容層的範圍內。
|
||||
呼叫它們的腳本不會如預期運作。
|
||||
× 透過 require 載入模組,以及 io / dofile 等任意檔案存取
|
||||
|
||||
@@ -98,6 +98,9 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
| `obj.rxr`, `obj.ryr`, `obj.rzr` | 変更可 | 回転角(ラジアン)。同名の度数版より優先して反映される |
|
||||
| `obj.w`, `obj.h`, `obj.hw`, `obj.hh`, `obj.cx`, `obj.cy`, `obj.cz`, `obj.diagonal` | 読み取り専用 | 入力画像のサイズ・中心座標・対角線長 |
|
||||
| `obj.track0`〜`obj.track3` | 読み取り専用 | トラックバーの現在値(後述) |
|
||||
| `obj.slider0`〜`obj.slider3` | 読み取り専用 | 整数スライダーの現在値(後述) |
|
||||
| `obj.text`, `obj.font`, `obj.dir` | 読み取り専用 | テキスト入力欄の文字列、フォント名、フォルダパス(後述) |
|
||||
| `obj.file_video`〜`obj.file_shader` | 読み取り専用 | 各ファイル選択欄のパス(後述) |
|
||||
| `obj.time`, `obj.frame`, `obj.totalframe`, `obj.totaltime`, `obj.t`, `obj.framerate`, `obj.layer`, `obj.index`, `obj.num` | 読み取り専用 | 時間・フレーム・レイヤー等の情報 |
|
||||
|
||||
### 3. ピクセル操作機能
|
||||
@@ -177,6 +180,10 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
エフェクトパネルには 4 本のトラックバー(アニメーション対応)があり、各値はスクリプト内で `obj.track0`〜`obj.track3` として参照できます。スライダー表示範囲はいずれも -100〜100、デフォルト値は 0、表示形式は小数点以下2桁です。トラックバーは常に表示されます。
|
||||
|
||||
チェックボックス(`obj.check0`〜`obj.check3`)とカラーピッカー(`color`)は、スクリプト本体でそれらを参照すると自動的にエフェクトパネルへ表示されます(参照を消すと非表示に戻ります)。これにより、`--` ヘッダを書かなくても必要な入力欄だけを出せます。なお、この一般利用ではスライダーのようなラベル・範囲・既定値の宣言は伴わないため、値の範囲はスクリプト内で扱ってください。AviUtl 互換の `--track`/`--check`/`--color` ヘッダによる宣言表示は従来どおり利用できます([AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。
|
||||
|
||||
数値スライダーが 4 本あり、各値はスクリプト内で `obj.slider0`〜`obj.slider3` として参照できます。値は整数で、表示範囲は `obj.slider0` が 1〜10、`obj.slider1` が 0〜100、`obj.slider2` が 0〜1000、`obj.slider3` が -1000〜1000 です。状態の切り替えなど、補間を伴わない整数値の受け渡しに使えます。
|
||||
|
||||
文字列パラメータも利用できます。テキスト入力欄は `obj.text`、フォント選択欄は `obj.font`、フォルダ選択欄は `obj.dir` で参照します。ファイル選択欄は種類ごとに `obj.file_video` / `obj.file_audio` / `obj.file_image` / `obj.file_project` / `obj.file_mp4` / `obj.file_exo` / `obj.file_subtitle` / `obj.file_shader` で参照し、選択したファイルのパスを取得できます。取得したパスは `obj.load` へ渡して画像・動画の読み込みに使えます。スライダーと文字列パラメータは、スクリプト本体でそれらを参照すると自動的にエフェクトパネルへ表示されます。いずれのパラメータも MoonSharp とネイティブの両エンジンから参照できます。
|
||||
|
||||
### 7. スクリプトエディタの支援機能
|
||||
|
||||
@@ -206,11 +213,13 @@ AviUtl のアニメーション効果スクリプト(`.anm` 系)のうち、
|
||||
- **`@` による複数セクション**: 1 つのスクリプトに `@名前` で複数の効果が定義されている場合、先頭のセクションのみを実行します。
|
||||
- **`obj.rand(st, ed [, seed [, frame]])`**: 指定範囲(`st`〜`ed`)の整数を返す決定論的な乱数です。`seed` と `frame` が同じであれば常に同じ値を返し、`frame` を省略すると現在のフレームを用います。従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)で同じ値を返します。
|
||||
- **`obj.load("figure", 名前, 色, サイズ [, ライン [, アスペクト]])`**: 円・四角形・三角形・五角形・六角形・星形を生成し、オブジェクトのバッファを置き換えて描画します(出力は図形サイズに合わせて生成され、中心に配置されます)。`ライン` を省略するか `0` で塗りつぶし、サイズ以上の値でも塗りつぶしになります。`アスペクト`(-1.0〜1.0)で幅・高さを歪曲できます。
|
||||
- **描画・メディア・バッファ・オプション API**: `obj.draw` / `obj.drawpoly` による描画合成、`obj.load` の `"text"` / `"image"` / `"movie"`、`obj.setfont`、`obj.copybuffer`、`obj.effect`、`obj.getvalue`、`obj.setoption` / `obj.getoption` / `obj.pixeloption` に対応しています。これらは従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。
|
||||
- **描画・メディア・バッファ・オプション API**: `obj.draw` / `obj.drawpoly` による描画合成、`obj.load` の `"text"` / `"image"` / `"movie"`、`obj.setfont`、`obj.copybuffer`、`obj.effect`、`obj.getvalue`、`obj.setoption` / `obj.getoption` / `obj.pixeloption` に対応しています。これらは従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。`obj.setoption` では `antialias` に加えて、`obj.draw` / `obj.drawpoly` の合成モードを YMM4 の並びで指定する `blend`、描画先を `"framebuffer"` / `"tempbuffer"` で切り替える `drawtarget`、作業画像の出力可否を切り替える `draw_state` に対応します。
|
||||
- **`obj.setanchor(name, count [, option, ...])`**: プレビュー上にドラッグ可能なアンカーポイントを表示し、その座標を `name` の Lua 変数(`pos={x0,y0,x1,y1,…}`、`"xyz"` 指定時は `{x0,y0,z0,…}`)へ格納します。座標はオブジェクトの中心が原点で、ドラッグで調整した値はプロジェクトへ保存されます。最大 32 個で、`"line"` / `"loop"` / `"star"` / `"arm"` の線結びと `"xyz"` の 3D 指定に対応します。設置数を返し、従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。`name` に `"track"` を指定するトラックバー連携は未対応です。
|
||||
- **`obj.effect` の AviUtl/AviUtl2 互換マップ**: `obj.effect("エフェクト名", "パラメータ名", 値, …)` はまず互換マップを参照し、AviUtl/AviUtl2 の名前として宣言したエフェクトを、対応する YMM4 の映像エフェクトとプロパティへ変換して適用します。値の倍率とオフセットの変換まで宣言できます。互換マップに宣言が無い名前は、従来どおり YMM4 のエフェクト名・キーワードでそのまま解決するため、既存の呼び出しはそのまま動きます。この互換マップは YMM4 自身が AviUtl の `.exo` へ書き出す変換を逆向きにたどって構築しているため、往復しても結果が一致します。対象のエンジンは指定子 `--!aviutl` または `--!aviutl2` で切り替え、指定子を書かないときは `--!aviutl` として扱います。互換マップが対応するエフェクト名の一覧はドキュメントの「obj の関数」を参照してください。
|
||||
|
||||
次のような機能は、この互換層では対象外です(呼び出しを含むスクリプトは意図どおりには動作しません)。
|
||||
|
||||
- `obj.setanchor`、`scene.set` / `scene.get` などの未実装関数
|
||||
- `scene.set` / `scene.get` などの未実装関数
|
||||
- `require` によるモジュール読み込み、`io` / `dofile` などの任意ファイルアクセス(`obj.load("image"/"movie")` のみ、先頭ヘッダー検証付きで対応)
|
||||
|
||||
---
|
||||
@@ -279,6 +288,14 @@ CPU / GPU カーネルが成立するのは、四則演算・`math.*`・比較
|
||||
| **Track1** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track1` として参照できる汎用パラメータ |
|
||||
| **Track2** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track2` として参照できる汎用パラメータ |
|
||||
| **Track3** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track3` として参照できる汎用パラメータ |
|
||||
| **Slider0** | 整数 | 1 | 1 〜 10 | - | `obj.slider0` として参照できる整数パラメータ |
|
||||
| **Slider1** | 整数 | 0 | 0 〜 100 | - | `obj.slider1` として参照できる整数パラメータ |
|
||||
| **Slider2** | 整数 | 0 | 0 〜 1000 | - | `obj.slider2` として参照できる整数パラメータ |
|
||||
| **Slider3** | 整数 | 0 | -1000 〜 1000 | - | `obj.slider3` として参照できる整数パラメータ |
|
||||
| **Text** | 文字列 | 空 | - | - | `obj.text` として参照できるテキスト入力 |
|
||||
| **Font** | 文字列 | メイリオ | - | - | `obj.font` として参照できるフォント名 |
|
||||
| **Directory** | 文字列 | 空 | - | - | `obj.dir` として参照できるフォルダパス |
|
||||
| **FileVideo**〜**FileShader** | 文字列 | 空 | - | - | `obj.file_video`〜`obj.file_shader` として参照できるファイルパス |
|
||||
|
||||
---
|
||||
|
||||
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>anim ライブラリ | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>anim ライブラリ</h1>
|
||||
|
||||
<p>
|
||||
<code>anim</code> は、アニメーションでよく使う計算をまとめた補助ライブラリです。
|
||||
補間・イージング・波・範囲変換・ベクトル・ノイズ・色変換と、便利な定数を提供します。
|
||||
これらは標準 Lua にはない、このエフェクト独自の関数です。
|
||||
</p>
|
||||
|
||||
<h2>定数</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>定数</th><th>値</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.tau</code></td><td><code>math.pi * 2</code></td><td>円一周分のラジアン。周期運動に使う</td></tr>
|
||||
<tr><td><code>anim.e</code></td><td>ネイピア数</td><td>自然対数の底</td></tr>
|
||||
<tr><td><code>anim.phi</code></td><td><code>(1 + sqrt(5)) / 2</code></td><td>黄金比</td></tr>
|
||||
<tr><td><code>anim.sqrt2</code></td><td><code>sqrt(2)</code></td><td>2 の平方根</td></tr>
|
||||
</table>
|
||||
|
||||
<pre><code>obj.x = obj.x + math.sin(time * anim.tau) * 100</code></pre>
|
||||
|
||||
<h2>補間・イージング</h2>
|
||||
|
||||
<p>
|
||||
イージング関数はおおむね 0.0 ~ 1.0 の進行度 <code>t</code> を受け取り、変化のカーブを返します。
|
||||
<code>obj.t</code> をそのまま渡すのが定番です。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.lerp(a, b, t)</code></td><td><code>a</code> と <code>b</code> を <code>t</code> で線形補間</td></tr>
|
||||
<tr><td><code>anim.smoothstep(e0, e1, x)</code></td><td><code>e0</code> ~ <code>e1</code> をエルミート補間で滑らかに遷移</td></tr>
|
||||
<tr><td><code>anim.smootherstep(e0, e1, x)</code></td><td>2 次導関数まで連続な、より滑らかな遷移</td></tr>
|
||||
<tr><td><code>anim.ease_in(t)</code></td><td>2 次イーズイン(加速)</td></tr>
|
||||
<tr><td><code>anim.ease_out(t)</code></td><td>2 次イーズアウト(減速)</td></tr>
|
||||
<tr><td><code>anim.ease_in_out(t)</code></td><td>2 次イーズイン・アウト(加速後減速)</td></tr>
|
||||
<tr><td><code>anim.elastic(t)</code></td><td>弾むようなスプリングイージング(t は 0 ~ 1 にクランプ)</td></tr>
|
||||
<tr><td><code>anim.back(t)</code></td><td>行き過ぎてから戻るイージング</td></tr>
|
||||
<tr><td><code>anim.bounce(t)</code></td><td>バウンドするイージング(t は 0 ~ 1 にクランプ)</td></tr>
|
||||
<tr><td><code>anim.step(edge, x)</code></td><td><code>x</code> が <code>edge</code> 以上なら 1.0、未満なら 0.0</td></tr>
|
||||
<tr><td><code>anim.bezier(t, p0, p1, p2, p3)</code></td><td><code>t</code> における 3 次ベジェ曲線の値(t は 0 ~ 1 にクランプ)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>2 点間をイージングで移動</h3>
|
||||
<pre><code>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)</code></pre>
|
||||
|
||||
<h3>弾むように登場</h3>
|
||||
<pre><code>local p = anim.duration(time, 0.3)
|
||||
obj.zoom = obj.zoom * anim.elastic(p)</code></pre>
|
||||
|
||||
<h2>範囲・周期</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.clamp(v, lo, hi)</code></td><td><code>v</code> を <code>lo</code> ~ <code>hi</code> に収める</td></tr>
|
||||
<tr><td><code>anim.map(v, a1, b1, a2, b2)</code></td><td>範囲 <code>a1</code>~<code>b1</code> の <code>v</code> を <code>a2</code>~<code>b2</code> に変換</td></tr>
|
||||
<tr><td><code>anim.norm(v, lo, hi)</code></td><td><code>v</code> が <code>lo</code>~<code>hi</code> のどの割合(0.0~1.0)かを返す</td></tr>
|
||||
<tr><td><code>anim.wrap(v, lo, hi)</code></td><td><code>v</code> を <code>lo</code> ~ <code>hi</code> でループさせる</td></tr>
|
||||
<tr><td><code>anim.pingpong(t, len)</code></td><td>0 ~ <code>len</code> を往復する値</td></tr>
|
||||
<tr><td><code>anim.sign(v)</code></td><td>符号(正=1, 負=-1, ゼロ=0)</td></tr>
|
||||
<tr><td><code>anim.fract(v)</code></td><td>小数部分のみ</td></tr>
|
||||
<tr><td><code>anim.oscillate(t, lo, hi, freq)</code></td><td>周波数 <code>freq</code> で <code>lo</code>~<code>hi</code> を正弦波で往復</td></tr>
|
||||
<tr><td><code>anim.triangle(t, freq)</code></td><td>周波数 <code>freq</code> で 0.0~1.0 を往復する三角波</td></tr>
|
||||
<tr><td><code>anim.square(t, freq)</code></td><td>周波数 <code>freq</code> で 1.0 と 0.0 を切り替える矩形波</td></tr>
|
||||
<tr><td><code>anim.duration(t, dur)</code></td><td>時間 <code>dur</code> に対する割合(0.0~1.0、クランプあり)</td></tr>
|
||||
<tr><td><code>anim.delay(t, d)</code></td><td>時間 <code>d</code> を引いた値(0 未満は 0)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>値の範囲変換</h3>
|
||||
<pre><code>obj.rz = anim.map(obj.track0, 0, 100, -180, 180)</code></pre>
|
||||
|
||||
<h3>滑らかな明滅</h3>
|
||||
<pre><code>obj.alpha = anim.oscillate(time, 64, 255, 1)</code></pre>
|
||||
|
||||
<h2>ベクトル・幾何</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>戻り値</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.len(x, y)</code></td><td>数値</td><td>ベクトル (x, y) の長さ</td></tr>
|
||||
<tr><td><code>anim.dist(x1, y1, x2, y2)</code></td><td>数値</td><td>2 点間の距離</td></tr>
|
||||
<tr><td><code>anim.dot(x1, y1, x2, y2)</code></td><td>数値</td><td>2 ベクトルの内積</td></tr>
|
||||
<tr><td><code>anim.normalize(x, y)</code></td><td>x, y</td><td>正規化した方向ベクトル(2 値で返す)</td></tr>
|
||||
<tr><td><code>anim.polar(r, a)</code></td><td>x, y</td><td>半径 <code>r</code>・角度 <code>a</code>(度)から移動量</td></tr>
|
||||
<tr><td><code>anim.rotate(x, y, a)</code></td><td>x, y</td><td>(x, y) を <code>a</code>(度)回転させた座標</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>円運動</h3>
|
||||
<pre><code>local r = obj.track0
|
||||
local dx, dy = anim.polar(r, time * 90)
|
||||
obj.x = obj.x + dx
|
||||
obj.y = obj.y + dy</code></pre>
|
||||
|
||||
<h2>ノイズ・乱数</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.noise(x [, y [, z]])</code></td><td>1 ~ 3 次元の滑らかなノイズ(0.0 ~ 1.0)。同じ座標では常に同じ値</td></tr>
|
||||
<tr><td><code>anim.rand(s)</code></td><td>シード <code>s</code> に基づく 0.0 ~ 1.0 の安定した乱数</td></tr>
|
||||
<tr><td><code>anim.rand(max, s)</code></td><td>0.0 ~ <code>max</code> の安定した乱数</td></tr>
|
||||
<tr><td><code>anim.rand(min, max, s)</code></td><td><code>min</code> ~ <code>max</code> の安定した乱数</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
<code>anim.rand</code> はシードのみで決まる小数の乱数です(フレームは関与しません)。
|
||||
整数で、フレームによっても変えたい場合は <a href="obj-functions.html"><code>obj.rand</code></a> を使ってください。
|
||||
</div>
|
||||
|
||||
<h3>安定した乱数で個体差をつける</h3>
|
||||
<pre><code>local offset = anim.rand(-50, 50, obj.layer)
|
||||
obj.x = obj.x + offset</code></pre>
|
||||
|
||||
<h3>ノイズで揺らぐ手ぶれ風</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>色変換</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>戻り値</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.hsv_to_rgb(h, s, v)</code></td><td>r, g, b</td><td>HSV(色相 0~360, 彩度 0~1, 明度 0~1)を RGB(0~255)へ変換</td></tr>
|
||||
<tr><td><code>anim.rgb_to_hsv(r, g, b)</code></td><td>h, s, v</td><td>RGB(0~255)を HSV へ変換</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>時間で色相を回す</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<div class="pager">
|
||||
<a href="obj-functions.html">← obj の関数</a>
|
||||
<a href="scene-ymm4.html">scene と ymm4 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,241 @@
|
||||
(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" }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
var titleOf = {};
|
||||
for (var gi = 0; gi < NAV.length; gi++) {
|
||||
for (var ii = 0; ii < NAV[gi].items.length; ii++) {
|
||||
titleOf[NAV[gi].items[ii].href] = NAV[gi].items[ii].title;
|
||||
}
|
||||
}
|
||||
|
||||
var indexPromise = null;
|
||||
var searchTimer = null;
|
||||
|
||||
function currentFile() {
|
||||
var path = window.location.pathname;
|
||||
var file = path.substring(path.lastIndexOf("/") + 1);
|
||||
return file === "" ? "index.html" : file;
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
function build() {
|
||||
var here = currentFile();
|
||||
var sidebar = document.getElementById("sidebar");
|
||||
if (!sidebar) return;
|
||||
|
||||
var html = '<a class="brand" href="index.html">Lua スクリプト for YMM4</a>';
|
||||
html += '<input id="navfilter" type="search" placeholder="全ページを検索" aria-label="全ページを検索" autocomplete="off">';
|
||||
html += '<div id="navresults"></div>';
|
||||
html += '<div id="navtree">';
|
||||
for (var i = 0; i < NAV.length; i++) {
|
||||
html += '<div class="group">' + NAV[i].group + "</div><ul>";
|
||||
for (var j = 0; j < NAV[i].items.length; j++) {
|
||||
var it = NAV[i].items[j];
|
||||
var cls = it.href === here ? ' class="active"' : "";
|
||||
html += "<li><a" + cls + ' href="' + it.href + '">' + it.title + "</a></li>";
|
||||
}
|
||||
html += "</ul>";
|
||||
}
|
||||
html += "</div>";
|
||||
sidebar.innerHTML = html;
|
||||
|
||||
var filter = document.getElementById("navfilter");
|
||||
filter.addEventListener("input", function () {
|
||||
var q = filter.value.trim();
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(function () { runSearch(q); }, 150);
|
||||
});
|
||||
}
|
||||
|
||||
function runSearch(query) {
|
||||
var tree = document.getElementById("navtree");
|
||||
var results = document.getElementById("navresults");
|
||||
if (!tree || !results) return;
|
||||
|
||||
if (query.length < 2) {
|
||||
results.innerHTML = "";
|
||||
tree.style.display = "";
|
||||
return;
|
||||
}
|
||||
|
||||
tree.style.display = "none";
|
||||
results.innerHTML = '<div class="navmsg">検索中…</div>';
|
||||
|
||||
buildIndex().then(function (sections) {
|
||||
if (document.getElementById("navfilter").value.trim() !== query) return;
|
||||
render(results, sections, query);
|
||||
});
|
||||
}
|
||||
|
||||
function buildIndex() {
|
||||
if (indexPromise) return indexPromise;
|
||||
|
||||
var hrefs = [];
|
||||
for (var key in titleOf) {
|
||||
if (Object.prototype.hasOwnProperty.call(titleOf, key)) hrefs.push(key);
|
||||
}
|
||||
|
||||
indexPromise = Promise.all(hrefs.map(fetchSections)).then(function (lists) {
|
||||
var all = [];
|
||||
for (var i = 0; i < lists.length; i++) {
|
||||
for (var j = 0; j < lists[i].length; j++) all.push(lists[i][j]);
|
||||
}
|
||||
return all;
|
||||
});
|
||||
return indexPromise;
|
||||
}
|
||||
|
||||
function fetchSections(href) {
|
||||
return fetch(href)
|
||||
.then(function (res) { return res.text(); })
|
||||
.then(function (text) {
|
||||
var doc = new DOMParser().parseFromString(text, "text/html");
|
||||
var main = doc.querySelector("main");
|
||||
if (!main) return [];
|
||||
|
||||
var sections = [];
|
||||
var heading = "";
|
||||
var buffer = "";
|
||||
var children = main.children;
|
||||
|
||||
function flush() {
|
||||
var body = buffer.replace(/\s+/g, " ").trim();
|
||||
if (body.length > 0) {
|
||||
sections.push({
|
||||
href: href,
|
||||
page: titleOf[href] || href,
|
||||
heading: heading,
|
||||
text: body,
|
||||
lower: body.toLowerCase()
|
||||
});
|
||||
}
|
||||
buffer = "";
|
||||
}
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var el = children[i];
|
||||
var tag = el.tagName;
|
||||
if (tag === "H2" || tag === "H3") {
|
||||
flush();
|
||||
heading = el.textContent.replace(/\s+/g, " ").trim();
|
||||
} else if (el.className === "pager") {
|
||||
continue;
|
||||
} else {
|
||||
buffer += " " + el.textContent;
|
||||
}
|
||||
}
|
||||
flush();
|
||||
return sections;
|
||||
})
|
||||
.catch(function () { return []; });
|
||||
}
|
||||
|
||||
function render(container, sections, query) {
|
||||
var q = query.toLowerCase();
|
||||
var hits = [];
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var s = sections[i];
|
||||
var inHeading = s.heading.toLowerCase().indexOf(q) !== -1;
|
||||
var inPage = s.page.toLowerCase().indexOf(q) !== -1;
|
||||
var pos = s.lower.indexOf(q);
|
||||
if (inHeading || inPage || pos !== -1) {
|
||||
hits.push({ section: s, pos: pos, rank: inHeading || inPage ? 0 : 1 });
|
||||
}
|
||||
}
|
||||
|
||||
hits.sort(function (a, b) { return a.rank - b.rank; });
|
||||
|
||||
if (hits.length === 0) {
|
||||
container.innerHTML = '<div class="navmsg">「' + escapeHtml(query) + "」に一致する内容はありません。</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
var max = Math.min(hits.length, 40);
|
||||
var html = '<div class="navmsg">' + hits.length + " 件</div>";
|
||||
for (var k = 0; k < max; k++) {
|
||||
var s2 = hits[k].section;
|
||||
var label = s2.heading ? s2.page + " — " + s2.heading : s2.page;
|
||||
var anchor = s2.heading ? "#:~:text=" + encodeURIComponent(s2.heading) : "";
|
||||
html +=
|
||||
'<a class="navhit" href="' + s2.href + anchor + '">' +
|
||||
'<span class="h">' + escapeHtml(label) + "</span>" +
|
||||
'<span class="s">' + snippet(s2.text, hits[k].pos, query) + "</span>" +
|
||||
"</a>";
|
||||
}
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function snippet(text, pos, query) {
|
||||
if (pos < 0) {
|
||||
return escapeHtml(text.substring(0, 70)) + (text.length > 70 ? "…" : "");
|
||||
}
|
||||
var start = Math.max(0, pos - 30);
|
||||
var end = Math.min(text.length, pos + query.length + 40);
|
||||
var before = (start > 0 ? "…" : "") + text.substring(start, pos);
|
||||
var hit = text.substring(pos, pos + query.length);
|
||||
var after = text.substring(pos + query.length, end) + (end < text.length ? "…" : "");
|
||||
return escapeHtml(before) + "<mark>" + escapeHtml(hit) + "</mark>" + escapeHtml(after);
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
var btn = document.getElementById("navtoggle");
|
||||
if (!btn) return;
|
||||
btn.addEventListener("click", function () {
|
||||
document.body.classList.toggle("nav-open");
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", function () { build(); toggle(); });
|
||||
} else {
|
||||
build();
|
||||
toggle();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,28 @@
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; font-family: sans-serif; line-height: 1.7; }
|
||||
#sidebar { position: fixed; top: 0; left: 0; width: 240px; height: 100vh; overflow: auto; border-right: 1px solid #ccc; padding: 1em; }
|
||||
#sidebar .brand { display: block; margin-bottom: .6em; font-weight: bold; text-decoration: none; color: #000; }
|
||||
#sidebar input { width: 100%; margin-bottom: .6em; }
|
||||
#sidebar .group { font-size: .8em; color: #666; margin-top: 1em; }
|
||||
#sidebar ul { list-style: none; margin: 0; padding: 0; }
|
||||
#sidebar li a { display: block; padding: .2em .4em; text-decoration: none; color: #000; }
|
||||
#sidebar li a.active { background: #0969da; color: #fff; }
|
||||
main { margin-left: 240px; max-width: 860px; padding: 1em 2em 4em; }
|
||||
pre { background: #f0f0f0; border: 1px solid #ccc; padding: .8em; overflow-x: auto; }
|
||||
code { background: #f0f0f0; padding: 0 .2em; }
|
||||
pre code { background: none; padding: 0; }
|
||||
table { border-collapse: collapse; margin: 1em 0; }
|
||||
th, td { border: 1px solid #ccc; padding: .3em .6em; text-align: left; vertical-align: top; }
|
||||
#navresults .navmsg { font-size: .8em; color: #666; margin: .4em 0; }
|
||||
#navresults .navhit { display: block; padding: .3em .4em; text-decoration: none; color: #000; border-top: 1px solid #eee; }
|
||||
#navresults .navhit .h { display: block; font-size: .82em; color: #0969da; }
|
||||
#navresults .navhit .s { display: block; font-size: .82em; color: #444; }
|
||||
.note, .warn { border-left: 3px solid #888; padding-left: .8em; margin: 1em 0; }
|
||||
.pager { display: flex; justify-content: space-between; margin-top: 2em; }
|
||||
#navtoggle { display: none; }
|
||||
@media (max-width: 820px) {
|
||||
#sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 9; background: #fff; }
|
||||
body.nav-open #sidebar { transform: none; }
|
||||
main { margin-left: 0; padding: 3em 1em; }
|
||||
#navtoggle { display: block; position: fixed; top: .5em; left: .5em; z-index: 10; }
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>パラメータ指定子 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>パラメータ指定子</h1>
|
||||
|
||||
<p>
|
||||
スクリプトの先頭などにコメント形式の指定子を書くと、パラメータパネルのトラックバーや
|
||||
チェックボックス、色の名前・範囲・既定値を定義できます。指定子は <code>--</code> で始まる
|
||||
コメント行なので、Lua の実行には影響しません。
|
||||
</p>
|
||||
|
||||
<div class="note">
|
||||
指定子は必須ではありません。<code>--</code> の行を書かなくても、
|
||||
トラックバーの値は <code>obj.track0</code> ~ <code>obj.track3</code> で読めます。
|
||||
チェックボックスの <code>obj.check0</code> ~ <code>obj.check3</code> と <code>color</code> も、
|
||||
スクリプト中で参照すればパネルに現れて使えます。指定子は、名前や範囲・既定値を整えたいときに使います。
|
||||
</div>
|
||||
|
||||
<div class="note">
|
||||
エンジンを選ぶ <code>--!native</code> などの指定子は別物です。先頭が <code>--!</code> で始まります。
|
||||
エンジンの指定は<a href="engines.html">エンジンと高速化</a>を参照してください。
|
||||
</div>
|
||||
|
||||
<h2>トラックバー</h2>
|
||||
|
||||
<p>
|
||||
<code>--track0:</code> ~ <code>--track3:</code> で、各トラックバーの名前・範囲・既定値・増分を指定します。
|
||||
書式はカンマ区切りです。
|
||||
</p>
|
||||
|
||||
<pre><code>--track0:振幅,0,200,50
|
||||
--track1:周波数,0,10,1,0.1</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>項目</th><th>位置</th><th>省略時</th></tr>
|
||||
<tr><td>名前</td><td>1 番目</td><td>空</td></tr>
|
||||
<tr><td>最小値</td><td>2 番目</td><td>0</td></tr>
|
||||
<tr><td>最大値</td><td>3 番目</td><td>100</td></tr>
|
||||
<tr><td>既定値</td><td>4 番目</td><td>最小値</td></tr>
|
||||
<tr><td>増分</td><td>5 番目</td><td>0</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
最大値が最小値より小さい場合は自動で入れ替わり、既定値は範囲内にクランプされます。
|
||||
値はスクリプトから <code>obj.track0</code> ~ <code>obj.track3</code> で読めます。
|
||||
</p>
|
||||
|
||||
<h2>チェックボックス</h2>
|
||||
|
||||
<p>
|
||||
<code>--check0:</code> ~ <code>--check3:</code> で、名前と既定値(0 で off、0 以外で on)を指定します。
|
||||
値は <code>obj.check0</code> ~ <code>obj.check3</code> で読めます。
|
||||
</p>
|
||||
|
||||
<pre><code>--check0:反転を有効にする,0</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>項目</th><th>位置</th><th>省略時</th></tr>
|
||||
<tr><td>名前</td><td>1 番目</td><td>空</td></tr>
|
||||
<tr><td>既定値</td><td>2 番目</td><td>0(off)</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>色</h2>
|
||||
|
||||
<p>
|
||||
<code>--color:</code> で Color パラメータの既定色を指定します。
|
||||
<code>0xRRGGBB</code> 形式または 10 進整数で書けます。値はグローバルの <code>color</code> で読めます。
|
||||
</p>
|
||||
|
||||
<pre><code>--color:0xFF8800</code></pre>
|
||||
|
||||
<h2>表示条件</h2>
|
||||
|
||||
<p>パラメータの表示・非表示は次のルールで決まります。</p>
|
||||
|
||||
<ul>
|
||||
<li>トラックバー: 指定子がまったく無い場合は 4 本すべて表示。
|
||||
いずれかの <code>--track@:</code> を書いた場合は、宣言したトラックのみ表示。</li>
|
||||
<li>チェックボックス: <code>--check@:</code> を書いた場合、または指定子がまったく無く
|
||||
スクリプト中で <code>obj.check@</code> を使っている場合に表示。</li>
|
||||
<li>色: <code>--color:</code> を書いた場合、または指定子がまったく無く
|
||||
スクリプト中で <code>color</code> を使っている場合に表示。</li>
|
||||
</ul>
|
||||
|
||||
<h2>セクション(@)</h2>
|
||||
|
||||
<p>
|
||||
行頭が <code>@</code> の行はセクションの区切りです。セクションを使う場合、
|
||||
指定子と本文は最初のセクションから読み取られます。通常のスクリプトでは <code>@</code> を使わず、
|
||||
指定子をスクリプト先頭にコメントとして並べれば十分です。
|
||||
</p>
|
||||
|
||||
<h2>AviUtl 互換の宣言(dialog / param)</h2>
|
||||
|
||||
<p>
|
||||
<code>--dialog:</code> と <code>--param:</code> は、AviUtl のダイアログ変数に近い書き方で、
|
||||
本文の先頭に Lua の宣言を差し込みます。差し込まれた行は本体より前に実行されます。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>指定子</th><th>説明</th></tr>
|
||||
<tr><td><code>--param:宣言</code></td><td>指定した宣言を本文の先頭に追加する</td></tr>
|
||||
<tr><td><code>--dialog:ラベル,宣言; ...</code></td><td><code>;</code> 区切りの各項目について、最初の <code>,</code> の後ろを宣言として先頭に追加する</td></tr>
|
||||
</table>
|
||||
|
||||
<pre><code>--param:local speed = 90
|
||||
obj.rz = time * speed</code></pre>
|
||||
|
||||
<h2>AviUtl 互換マップの対象エンジン</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.effect</code> が参照する互換マップの対象エンジンを切り替えます。
|
||||
指定子 <code>--!aviutl</code> または <code>--!aviutl2</code> を書くと、
|
||||
そのエンジンに対応するエフェクトだけを解決します。
|
||||
指定子を書かないときは <code>--!aviutl</code> として扱います。詳細は
|
||||
<a href="obj-functions.html">obj の関数</a>を参照してください。
|
||||
</p>
|
||||
|
||||
<pre><code>--!aviutl2
|
||||
obj.effect("ぼかし", "範囲", 20)</code></pre>
|
||||
|
||||
<div class="pager">
|
||||
<a href="engines.html">← エンジンと高速化</a>
|
||||
<a href="samples.html">サンプル集 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>エンジンと高速化 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>エンジンと高速化</h1>
|
||||
|
||||
<p>
|
||||
このプラグインには複数の実行エンジンがあります。標準は MoonSharp ですが、重いピクセル処理のために
|
||||
LuaJIT ネイティブレーンや、CPU / GPU カーネルへ変換するレーンを選べます。
|
||||
座標などを動かすだけのスクリプトでは MoonSharp で十分速く、エンジンを意識する必要はありません。
|
||||
</p>
|
||||
|
||||
<h2>エンジンの種類</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>エンジン</th><th>指定子</th><th>特徴</th></tr>
|
||||
<tr><td>MoonSharp</td><td><code>--!moonsharp</code>(既定)</td><td>Lua 5.2 互換。全機能が使える標準エンジン</td></tr>
|
||||
<tr><td>ネイティブ(LuaJIT)</td><td><code>--!native</code></td><td>別プロセスの LuaJIT で実行。ピクセル処理が大幅に高速</td></tr>
|
||||
<tr><td>CPU カーネル</td><td><code>--!cpu</code></td><td>決まった形のピクセルループを並列実行に変換。MoonSharp と一致する結果</td></tr>
|
||||
<tr><td>GPU カーネル</td><td><code>--!gpu</code></td><td>ピクセルループを GPU シェーダーに変換。最速だが float32 精度(明示指定のみ)</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
スライダー <code>obj.slider0</code> ~ <code>obj.slider3</code> と文字列パラメータ
|
||||
<code>obj.text</code> / <code>obj.font</code> / <code>obj.dir</code> / <code>obj.file_*</code> は、
|
||||
MoonSharp とネイティブのどちらのエンジンでも同じ名前で参照できます。
|
||||
CPU カーネルと GPU カーネルは数値計算に特化するため、文字列を扱いません。
|
||||
</div>
|
||||
|
||||
<h2>指定子の書き方</h2>
|
||||
|
||||
<p>
|
||||
エンジンの指定子は <code>--!</code> で始まる 1 行です。トークンの前後の空白以外に文字があってはいけません。
|
||||
スクリプトのどの行に書いても構いません。
|
||||
</p>
|
||||
|
||||
<pre><code>--!native
|
||||
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, 255 - g, 255 - b, a)
|
||||
end
|
||||
end</code></pre>
|
||||
|
||||
<h2>自動振り分け</h2>
|
||||
|
||||
<p>指定子が無いときは、スクリプトの内容から自動でエンジンが選ばれます。</p>
|
||||
|
||||
<ul>
|
||||
<li>後述のカーネル条件に当てはまるピクセルループは、CPU カーネルで実行します。結果は MoonSharp と一致します。</li>
|
||||
<li><code>obj.setoption</code> を使う描画系のスクリプトは、MoonSharp で実行します。</li>
|
||||
<li>カーネル条件には当てはまらないものの <code>getpixel</code> や <code>setpixel</code> を使うスクリプトは、ネイティブが使えればネイティブで実行します。</li>
|
||||
<li>それ以外は MoonSharp で実行します。</li>
|
||||
</ul>
|
||||
|
||||
<div class="note">
|
||||
明示した指定子は自動振り分けより優先されます。
|
||||
<code>--!gpu</code> は明示したときだけ使われ、自動では選ばれません(精度が float32 のため)。
|
||||
</div>
|
||||
|
||||
<h2>カーネルに変換できる形</h2>
|
||||
|
||||
<p>
|
||||
CPU / GPU カーネルは、次の決まった形のスクリプトだけを変換します。条件に合わないスクリプトは
|
||||
カーネルにならず、自動でほかのエンジンへフォールバックします(結果は変わりません)。
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>先頭に <code>local</code> 宣言を置いてもよい。</li>
|
||||
<li>本体は二重の数値 for ループ 1 組だけ。外側と内側で <code>obj.h</code> と <code>obj.w</code> をそれぞれ
|
||||
<code>0</code> から <code>-1</code> まで回す。</li>
|
||||
<li>内側ループの最初が <code>local r, g, b[, a] = obj.getpixel(x, y)</code>、最後が
|
||||
<code>obj.setpixel(x, y, ...)</code>。</li>
|
||||
<li>その間は <code>local</code> 宣言と代入のみ。</li>
|
||||
</ul>
|
||||
|
||||
<p>カーネル内で使える要素は限られます。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>分類</th><th>使えるもの</th></tr>
|
||||
<tr><td>演算子</td><td><code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>%</code> <code>^</code>、単項マイナス、条件式 <code>cond and a or b</code></td></tr>
|
||||
<tr><td>math 関数</td><td><code>abs, floor, ceil, sqrt, sin, cos, tan, asin, acos, atan, atan2, exp, log, pow, fmod, min, max</code></td></tr>
|
||||
<tr><td>math 定数</td><td><code>math.pi</code>, <code>math.huge</code></td></tr>
|
||||
<tr><td>条件</td><td>比較(<code>< > <= >= == ~=</code>)、<code>and</code> / <code>or</code> / <code>not</code>、<code>obj.check0</code> ~ <code>obj.check3</code></td></tr>
|
||||
<tr><td>参照できる値</td><td>座標 <code>x</code> / <code>y</code>、<code>obj</code> の各フィールド、<code>scene.width/height/cx/cy</code>、
|
||||
<code>time, frame, totalframe, framerate, timelineframe, timelinetime, layer, color</code></td></tr>
|
||||
</table>
|
||||
|
||||
<h3>カーネルになるグレースケールの例</h3>
|
||||
<pre><code>for y = 0, obj.h - 1 do
|
||||
for x = 0, obj.w - 1 do
|
||||
local r, g, b, a = obj.getpixel(x, y)
|
||||
local gray = r * 0.299 + g * 0.587 + b * 0.114
|
||||
obj.setpixel(x, y, gray, gray, gray, a)
|
||||
end
|
||||
end</code></pre>
|
||||
|
||||
<h2>フォールバックの動き</h2>
|
||||
|
||||
<ul>
|
||||
<li><code>--!native</code> を指定しても、プラグインの隣に <code>native</code> フォルダが配置されていない場合は
|
||||
MoonSharp で実行されます(ログに一度だけ警告が出ます)。期待した高速化が得られないときは、
|
||||
ビルド・配置に <code>native</code> フォルダが含まれているか確認してください。</li>
|
||||
<li><code>--!gpu</code> を指定しても、GPU カーネルを初期化できない場合は CPU カーネル、さらに MoonSharp の順で
|
||||
フォールバックします。</li>
|
||||
<li><code>--!cpu</code> を指定してもカーネル条件に合わないスクリプトは、ほかのエンジンで実行されます。</li>
|
||||
</ul>
|
||||
|
||||
<div class="warn">
|
||||
GPU カーネルは float32 精度で計算するため、MoonSharp / CPU カーネルとわずかに結果が異なることがあります。
|
||||
厳密に一致させたい場合は CPU カーネルかネイティブを使ってください。
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<a href="pixels.html">← ピクセル操作</a>
|
||||
<a href="directives.html">パラメータ指定子 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>導入と使い方 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>導入と使い方</h1>
|
||||
|
||||
<p>
|
||||
「Lua スクリプト」は映像エフェクトの一種です。アイテム(テキスト・画像・図形など)に対して、
|
||||
他のエフェクトと同じように追加して使います。
|
||||
</p>
|
||||
|
||||
<h2>エフェクトを追加する</h2>
|
||||
|
||||
<ol>
|
||||
<li>タイムライン上のアイテムを選択します。</li>
|
||||
<li>プロパティエリアのエフェクト欄で、フィルタ効果の追加から「Lua スクリプト」を選びます。
|
||||
検索欄では <code>lua</code> / <code>script</code> / <code>スクリプト</code> / <code>アニメーション効果</code> などのキーワードでも見つかります。</li>
|
||||
<li>追加すると、スクリプト入力欄と、トラックバーやチェックボックスなどのパラメータが表示されます。</li>
|
||||
</ol>
|
||||
|
||||
<h2>スクリプトエディタ</h2>
|
||||
|
||||
<p>スクリプト欄はコードエディタになっており、次の機能があります。</p>
|
||||
|
||||
<ul>
|
||||
<li>シンタックスハイライト: Lua の構文に色が付きます。</li>
|
||||
<li>入力補完: 識別子を入力すると候補が表示されます。<code>obj.</code> や <code>anim.</code> のように
|
||||
ドットを入力すると、そのテーブルのメンバーだけが候補に出ます。スクリプト内で定義した関数も補完されます。</li>
|
||||
<li>折りたたみ: <code>function ... end</code> などのブロックを折りたためます。</li>
|
||||
<li>エラー表示: 構文エラー・実行時エラー・タイムアウトが起きると、該当行に赤い波線で警告が表示されます。</li>
|
||||
</ul>
|
||||
|
||||
<h2>実行のしくみ</h2>
|
||||
|
||||
<p>
|
||||
スクリプトは表示中の各フレームで 1 回ずつ実行されます。
|
||||
プラグインは実行前に <code>obj</code>・<code>scene</code>・<code>ymm4</code> などへ現在の値を流し込み、
|
||||
スクリプトの実行後に <code>obj</code> の値を読み戻して描画へ反映します。
|
||||
</p>
|
||||
|
||||
<div class="note">
|
||||
グローバル変数(自分で <code>x = 1</code> のように作った変数)の状態はフレームをまたいで保持されません。
|
||||
毎フレーム、組み込み以外のグローバルはリセットされます。前のフレームの値を覚えておくことはできません。
|
||||
時間に応じた変化は <code>time</code> や <code>obj.t</code> から計算してください。
|
||||
</div>
|
||||
|
||||
<h2>はじめてのスクリプト</h2>
|
||||
|
||||
<p>既定のフェードインを、少しずつ拡張してみます。</p>
|
||||
|
||||
<h3>1. 不透明度を変える</h3>
|
||||
<pre><code>obj.alpha = math.min(time * 255, 255)</code></pre>
|
||||
|
||||
<h3>2. 横に動かす</h3>
|
||||
<pre><code>obj.alpha = math.min(time * 255, 255)
|
||||
obj.x = obj.x + math.sin(time * anim.tau) * 100</code></pre>
|
||||
|
||||
<h3>3. トラックバーで振幅を変える</h3>
|
||||
<p>
|
||||
パラメータパネルの <code>Track0</code> スライダーの値が <code>obj.track0</code> として読めます。
|
||||
スライダーを動かすと、揺れの大きさが変わります。
|
||||
</p>
|
||||
<pre><code>obj.alpha = math.min(time * 255, 255)
|
||||
obj.x = obj.x + math.sin(time * anim.tau) * obj.track0</code></pre>
|
||||
|
||||
<h2>パラメータパネル</h2>
|
||||
|
||||
<p>
|
||||
既定では <code>Track0</code> ~ <code>Track3</code> の 4 本のトラックバーが表示されます。
|
||||
チェックボックス(<code>Check0</code> ~ <code>Check3</code>)と色(<code>Color</code>)は、
|
||||
スクリプトでそれらを使うか、指定子で宣言したときに表示されます。
|
||||
表示条件と既定値・名前・範囲の指定方法は <a href="directives.html">パラメータ指定子</a> を参照してください。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>UI</th><th>スクリプトでの読み取り</th><th>型</th></tr>
|
||||
<tr><td>Track0 ~ Track3</td><td><code>obj.track0</code> ~ <code>obj.track3</code></td><td>数値</td></tr>
|
||||
<tr><td>Check0 ~ Check3</td><td><code>obj.check0</code> ~ <code>obj.check3</code></td><td>真偽値</td></tr>
|
||||
<tr><td>Color</td><td><code>color</code></td><td>数値 (0xRRGGBB)</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="warn">
|
||||
スクリプトの実行には 5 秒のタイムアウトがあります。無限ループや非常に重い処理は中断されます。
|
||||
詳しくは <a href="limits.html">制限事項とトラブル</a> を参照してください。
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<a href="index.html">← 概要</a>
|
||||
<a href="lua-basics.html">Lua の基礎 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>グローバル変数 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>グローバル変数</h1>
|
||||
|
||||
<p>
|
||||
スクリプトのグローバルスコープから直接参照できる変数です。
|
||||
これらは毎フレーム、実行前にプラグインが設定します。値は読み取り専用です
|
||||
(書き換えても描画には反映されません。描画を変えるには <a href="obj.html"><code>obj</code></a> を使います)。
|
||||
</p>
|
||||
|
||||
<h2>時間とフレーム</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>変数</th><th>型</th><th>説明</th></tr>
|
||||
<tr><td><code>time</code></td><td>数値</td><td>アイテム先頭からの経過時間(秒)。<code>obj.time</code> と同じ</td></tr>
|
||||
<tr><td><code>frame</code></td><td>整数</td><td>アイテム先頭からの現在フレーム番号。<code>obj.frame</code> と同じ</td></tr>
|
||||
<tr><td><code>totalframe</code></td><td>整数</td><td>アイテムの総フレーム数。<code>obj.totalframe</code> と同じ</td></tr>
|
||||
<tr><td><code>framerate</code></td><td>整数</td><td>フレームレート(fps)。<code>obj.framerate</code> と同じ</td></tr>
|
||||
<tr><td><code>timelineframe</code></td><td>整数</td><td>タイムライン先頭からの絶対フレーム番号</td></tr>
|
||||
<tr><td><code>timelinetime</code></td><td>数値</td><td>タイムライン基準の現在時間(秒)</td></tr>
|
||||
<tr><td><code>layer</code></td><td>整数</td><td>配置されているレイヤー番号。<code>obj.layer</code> と同じ</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<code>time</code> はアニメーションの基準としてもっともよく使います。
|
||||
アイテム内の進行割合(0.0 ~ 1.0)が欲しいときは <a href="obj.html"><code>obj.t</code></a> を使います。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.rz = time * 90
|
||||
obj.alpha = obj.t * 255</code></pre>
|
||||
|
||||
<h2>色</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>変数</th><th>型</th><th>説明</th></tr>
|
||||
<tr><td><code>color</code></td><td>数値</td><td>Color パラメータの色を <code>0xRRGGBB</code> の整数で表す</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<code>color</code> は、Color パラメータが表示されているとき(スクリプトで <code>color</code> を使うか、
|
||||
<a href="directives.html"><code>--color@</code></a> 指定子で宣言したとき)にのみ設定されます。
|
||||
各成分は次のように取り出せます。
|
||||
</p>
|
||||
|
||||
<pre><code>local r = bit32.rshift(bit32.band(color, 0xFF0000), 16)
|
||||
local g = bit32.rshift(bit32.band(color, 0x00FF00), 8)
|
||||
local b = bit32.band(color, 0x0000FF)</code></pre>
|
||||
|
||||
<h2>テーブル</h2>
|
||||
|
||||
<p>主要な機能は、グローバルに置かれた次のテーブルにまとまっています。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>テーブル</th><th>役割</th><th>参照</th></tr>
|
||||
<tr><td><code>obj</code></td><td>描画対象の座標・回転・拡大率・不透明度と各種関数</td><td><a href="obj.html">obj</a> / <a href="obj-functions.html">obj の関数</a></td></tr>
|
||||
<tr><td><code>anim</code></td><td>補間・波・ノイズ・色変換などのアニメーション関数</td><td><a href="anim.html">anim</a></td></tr>
|
||||
<tr><td><code>scene</code></td><td>シーンの解像度</td><td><a href="scene-ymm4.html">scene</a></td></tr>
|
||||
<tr><td><code>ymm4</code></td><td>グループ・タイムライン・再生状態などの環境情報</td><td><a href="scene-ymm4.html">ymm4</a></td></tr>
|
||||
</table>
|
||||
|
||||
<p>標準ライブラリのテーブルもグローバルに置かれています。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>テーブル</th><th>役割</th></tr>
|
||||
<tr><td><code>math</code></td><td>数学関数</td></tr>
|
||||
<tr><td><code>string</code></td><td>文字列操作</td></tr>
|
||||
<tr><td><code>table</code></td><td>テーブル操作</td></tr>
|
||||
<tr><td><code>bit32</code></td><td>ビット演算</td></tr>
|
||||
</table>
|
||||
|
||||
<p>これらの中身は <a href="stdlib.html">標準ライブラリ</a> にまとめています。</p>
|
||||
|
||||
<div class="pager">
|
||||
<a href="stdlib.html">← 標準ライブラリ</a>
|
||||
<a href="obj.html">obj オブジェクト →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+48
-598
@@ -3,628 +3,78 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Luaスクリプト for YMM4 サンプル集</title>
|
||||
<title>概要 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<img src="LuaScript.png" alt="Luaスクリプト for YMM4" width="640">
|
||||
|
||||
<h1>Luaスクリプト for YMM4 サンプル集</h1>
|
||||
<h1>Lua スクリプト for YMM4</h1>
|
||||
|
||||
<p>
|
||||
YukkuriMovieMaker4 の「Luaスクリプト」映像エフェクトで使えるサンプルと、
|
||||
利用可能な変数・関数・定数の一覧をまとめたページです。
|
||||
各サンプルはエフェクトのスクリプト欄にそのまま貼り付けて利用できます。
|
||||
スクリプトエンジンは MoonSharp (Lua 5.2 互換) です。
|
||||
YukkuriMovieMaker4 の映像エフェクト「Lua スクリプト」の公式ドキュメントです。
|
||||
このエフェクトでは、Lua のコードで映像を毎フレーム加工できます。座標・回転・拡大率・不透明度の制御から、
|
||||
ピクセル単位の画像処理、図形やテキストの生成、ほかのエフェクトの呼び出しまでを、1 つのスクリプト欄で行えます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
変数・関数の詳細な仕様は、スクリプトエディタのヘルプ、または
|
||||
<code>docs/LuaScript.ja-jp.txt</code> を参照してください。
|
||||
標準のスクリプトエンジンは Lua 5.2 互換の MoonSharp です。
|
||||
重いピクセル処理のためには、LuaJIT で実行する <code>--!native</code> レーンと、
|
||||
CPU・GPU カーネルへ変換する <code>--!cpu</code>・<code>--!gpu</code> レーンも用意しています。
|
||||
詳しくは<a href="engines.html">エンジンと高速化</a>を参照してください。
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<div class="note">
|
||||
このドキュメントは、プラグインの実装そのものに基づいて記述しています。
|
||||
変数・関数・定数の名前と挙動は、スクリプトエディタの入力補完に表示されるものと一致します。
|
||||
</div>
|
||||
|
||||
<h2>このドキュメントの構成</h2>
|
||||
|
||||
<h2>目次</h2>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#about">サンプルの読み方</a></li>
|
||||
<li><a href="#basic">1. 基本</a></li>
|
||||
<li><a href="#motion">2. 座標と動き</a></li>
|
||||
<li><a href="#rotation">3. 回転</a></li>
|
||||
<li><a href="#scale">4. 拡大・変形</a></li>
|
||||
<li><a href="#alpha">5. 不透明度・フェード</a></li>
|
||||
<li><a href="#ease">6. anim 補間・イージング</a></li>
|
||||
<li><a href="#range">7. anim 範囲・周期</a></li>
|
||||
<li><a href="#vector">8. anim ベクトル・幾何</a></li>
|
||||
<li><a href="#noise">9. anim ノイズ・乱数</a></li>
|
||||
<li><a href="#animcolor">10. anim 色</a></li>
|
||||
<li><a href="#const">11. anim 定数</a></li>
|
||||
<li><a href="#getobject">12. 他オブジェクトの参照 (obj.getobject)</a></li>
|
||||
<li><a href="#pixel">13. ピクセル操作</a></li>
|
||||
<li><a href="#scene">14. シーン情報 (scene)</a></li>
|
||||
<li><a href="#ymm4">15. 環境・メタ情報 (ymm4)</a></li>
|
||||
<li><a href="#globals">16. グローバル変数</a></li>
|
||||
<li><a href="#stdlib">17. 標準ライブラリ</a></li>
|
||||
<li><a href="#reference">クイックリファレンス</a></li>
|
||||
<li><a href="getting-started.html">導入と使い方</a> … エフェクトの追加方法と、エディタ・パラメータパネルの使い方を説明します。</li>
|
||||
<li><a href="lua-basics.html">Lua の基礎</a> … 変数・型・制御構文・関数・テーブルなど、Lua 言語そのものを学べます。</li>
|
||||
<li><a href="obj.html">obj オブジェクト</a> … 座標・回転・拡大率・不透明度など、描画を制御する中心のテーブルです。</li>
|
||||
<li><a href="anim.html">anim ライブラリ</a> … イージング・波・ノイズ・色変換など、アニメーション用の関数をまとめています。</li>
|
||||
<li><a href="pixels.html">ピクセル操作</a> … 画像を 1 ピクセルずつ読み書きする方法と注意点を説明します。</li>
|
||||
<li><a href="samples.html">サンプル集</a> … そのまま貼り付けて使えるスクリプトを集めています。</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<hr>
|
||||
<h2>最小の例</h2>
|
||||
|
||||
<h2 id="about">サンプルの読み方</h2>
|
||||
<p>
|
||||
スクリプト内では、変更可能な <code>obj</code> の値(座標・拡大率・回転・不透明度など)を
|
||||
書き換えると描画に反映されます。読み戻されるのは
|
||||
<code>x, y, z, ox, oy, zoom, aspect, alpha, rx, ry, rz</code>
|
||||
(およびラジアン版 <code>rxr, ryr, rzr</code>、独立スケール <code>sx, sy</code>)です。
|
||||
</p>
|
||||
<p>
|
||||
<code>time</code> はアイテム基準の経過秒数、<code>obj.t</code> はアイテム内の進行割合
|
||||
(0.0 ~ 1.0) です。グローバル変数の状態はフレーム間で保持されません。
|
||||
<code>math.random</code> は毎フレーム同じシードで初期化されるため、同一フレームでは
|
||||
同じ値を返します。安定した乱数が必要な場合は <code>anim.rand</code> を使います。
|
||||
</p>
|
||||
<p>エフェクトを追加した直後に入っている既定のスクリプトは、フェードインです。</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="basic">1. 基本</h2>
|
||||
|
||||
<h3>1-1. フェードイン (デフォルトスクリプト)</h3>
|
||||
<pre><code>obj.alpha = math.min(time * 255, 255)</code></pre>
|
||||
|
||||
<h3>1-2. フェードアウト</h3>
|
||||
<pre><code>obj.alpha = math.max((obj.totalframe - obj.frame) / obj.framerate * 255, 0)</code></pre>
|
||||
|
||||
<h3>1-3. Track0 で不透明度を制御</h3>
|
||||
<pre><code>obj.alpha = obj.track0</code></pre>
|
||||
|
||||
<h3>1-4. 時間に応じて回転</h3>
|
||||
<pre><code>obj.rz = time * 90</code></pre>
|
||||
|
||||
<h3>1-5. Track0 でズームを制御</h3>
|
||||
<pre><code>obj.zoom = obj.zoom * (1 + obj.track0 / 100)</code></pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="motion">2. 座標と動き</h2>
|
||||
|
||||
<h3>2-1. 左右の揺れ</h3>
|
||||
<p>Track0 を振幅(px)、Track1 を周波数(回/秒)として使います。</p>
|
||||
<pre><code>local amp = obj.track0
|
||||
local freq = obj.track1
|
||||
obj.x = obj.x + math.sin(time * anim.tau * freq) * amp</code></pre>
|
||||
|
||||
<h3>2-2. 円運動</h3>
|
||||
<pre><code>local r = obj.track0
|
||||
local dx, dy = anim.polar(r, time * 90)
|
||||
obj.x = obj.x + dx
|
||||
obj.y = obj.y + dy</code></pre>
|
||||
|
||||
<h3>2-3. バウンド (跳ねる)</h3>
|
||||
<pre><code>local h = obj.track0
|
||||
obj.y = obj.y - anim.bounce(anim.pingpong(time, 1)) * h</code></pre>
|
||||
|
||||
<h3>2-4. ゆらぎ (ノイズによる手ぶれ風)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>2-5. 中心オフセットを基準に振り子運動</h3>
|
||||
<p>回転中心 <code>ox, oy</code> をずらして振り子のように揺らします。</p>
|
||||
<pre><code>obj.oy = -obj.hh
|
||||
obj.rz = math.sin(time * anim.tau) * 30</code></pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="rotation">3. 回転</h2>
|
||||
|
||||
<h3>3-1. 度とラジアン</h3>
|
||||
<p>
|
||||
<code>rx, ry, rz</code> は度、<code>rxr, ryr, rzr</code> はラジアンです。
|
||||
ラジアン版を変更するとそちらが優先して反映されます。
|
||||
</p>
|
||||
<pre><code>obj.rzr = time * anim.tau</code></pre>
|
||||
|
||||
<h3>3-2. Y軸回転で立体的に回す</h3>
|
||||
<pre><code>obj.ry = time * 180</code></pre>
|
||||
|
||||
<h3>3-3. 加速しながら回転 (イージング)</h3>
|
||||
<pre><code>obj.rz = anim.ease_in(obj.t) * 360</code></pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="scale">4. 拡大・変形</h2>
|
||||
|
||||
<h3>4-1. 弾むように登場 (スケールイン)</h3>
|
||||
<pre><code>local p = anim.duration(time, 0.3)
|
||||
obj.zoom = obj.zoom * anim.elastic(p)</code></pre>
|
||||
|
||||
<h3>4-2. アスペクト比で横伸び・縦伸び</h3>
|
||||
<p>
|
||||
<code>aspect</code> は正で横方向に縮小、負で縦方向に縮小します。
|
||||
</p>
|
||||
<pre><code>obj.aspect = math.sin(time * anim.tau) * 0.5</code></pre>
|
||||
|
||||
<h3>4-3. X・Y を独立して拡大 (sx, sy)</h3>
|
||||
<p>ぷにぷにと潰れる動きを <code>sx, sy</code> で表現します。</p>
|
||||
<pre><code>local s = math.sin(time * anim.tau * 2) * 0.2
|
||||
obj.sx = 1 + s
|
||||
obj.sy = 1 - s</code></pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="alpha">5. 不透明度・フェード</h2>
|
||||
|
||||
<h3>5-1. 遅延フェードイン</h3>
|
||||
<pre><code>local p = anim.duration(anim.delay(time, 0.5), 1)
|
||||
obj.alpha = p * 255</code></pre>
|
||||
|
||||
<h3>5-2. 点滅 (矩形波)</h3>
|
||||
<pre><code>obj.alpha = anim.square(time, 4) * 255</code></pre>
|
||||
|
||||
<h3>5-3. 滑らかな明滅 (正弦波)</h3>
|
||||
<pre><code>obj.alpha = anim.oscillate(time, 64, 255, 1)</code></pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="ease">6. anim 補間・イージング</h2>
|
||||
|
||||
<h3>6-1. 2点間をイージングで移動</h3>
|
||||
<pre><code>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)</code></pre>
|
||||
|
||||
<h3>6-2. 行き過ぎてから戻る (back)</h3>
|
||||
<pre><code>obj.x = obj.x + anim.back(obj.t) * 200</code></pre>
|
||||
|
||||
<h3>6-3. しきい値で切り替え (step / smoothstep)</h3>
|
||||
<pre><code>obj.alpha = anim.smoothstep(0, 0.5, obj.t) * 255</code></pre>
|
||||
|
||||
<p>補間・イージング系関数の一覧です。</p>
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>anim.lerp(a, b, t)</td><td>a と b を t (0.0~1.0) で線形補間</td></tr>
|
||||
<tr><td>anim.smoothstep(e0, e1, x)</td><td>e0~e1 をエルミート補間で滑らかに遷移</td></tr>
|
||||
<tr><td>anim.smootherstep(e0, e1, x)</td><td>2次導関数まで連続な、より滑らかな遷移</td></tr>
|
||||
<tr><td>anim.ease_in(t)</td><td>2次イーズイン (加速)</td></tr>
|
||||
<tr><td>anim.ease_out(t)</td><td>2次イーズアウト (減速)</td></tr>
|
||||
<tr><td>anim.ease_in_out(t)</td><td>2次イーズイン・アウト (加速後減速)</td></tr>
|
||||
<tr><td>anim.elastic(t)</td><td>弾むようなスプリングイージング</td></tr>
|
||||
<tr><td>anim.back(t)</td><td>行き過ぎてから戻るイージング</td></tr>
|
||||
<tr><td>anim.bounce(t)</td><td>バウンドするイージング</td></tr>
|
||||
<tr><td>anim.step(edge, x)</td><td>x が edge 以上なら 1.0、未満なら 0.0</td></tr>
|
||||
<tr><td>anim.bezier(t, p0, p1, p2, p3)</td><td>t における3次ベジェ曲線の値</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="range">7. anim 範囲・周期</h2>
|
||||
|
||||
<h3>7-1. 値の範囲変換 (map)</h3>
|
||||
<pre><code>obj.rz = anim.map(obj.track0, 0, 100, -180, 180)</code></pre>
|
||||
|
||||
<h3>7-2. 三角波で往復</h3>
|
||||
<pre><code>obj.x = obj.x + (anim.triangle(time, 1) - 0.5) * 200</code></pre>
|
||||
|
||||
<p>範囲・周期系関数の一覧です。</p>
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>anim.clamp(v, lo, hi)</td><td>v を lo ~ hi の範囲に収める</td></tr>
|
||||
<tr><td>anim.map(v, a1, b1, a2, b2)</td><td>範囲 a1~b1 の v を a2~b2 に変換</td></tr>
|
||||
<tr><td>anim.norm(v, lo, hi)</td><td>v が lo~hi のどの割合 (0.0~1.0) かを取得</td></tr>
|
||||
<tr><td>anim.wrap(v, lo, hi)</td><td>v を lo ~ hi でループさせる</td></tr>
|
||||
<tr><td>anim.pingpong(t, len)</td><td>0 ~ len を往復する値</td></tr>
|
||||
<tr><td>anim.sign(v)</td><td>符号 (正=1, 負=-1, ゼロ=0)</td></tr>
|
||||
<tr><td>anim.fract(v)</td><td>小数部分のみを取得</td></tr>
|
||||
<tr><td>anim.oscillate(t, lo, hi, freq)</td><td>freq の周波数で lo~hi を正弦波で往復</td></tr>
|
||||
<tr><td>anim.triangle(t, freq)</td><td>freq の周波数で 0.0~1.0 を往復する三角波</td></tr>
|
||||
<tr><td>anim.square(t, freq)</td><td>freq の周波数で 1.0 と 0.0 を切り替える矩形波</td></tr>
|
||||
<tr><td>anim.duration(t, dur)</td><td>時間 dur に対する割合 (0.0~1.0, clamp あり)</td></tr>
|
||||
<tr><td>anim.delay(t, d)</td><td>時間 d 経過後から開始する時間 (0以下は0)</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="vector">8. anim ベクトル・幾何</h2>
|
||||
|
||||
<h3>8-1. 座標を回転させる</h3>
|
||||
<pre><code>local rx, ry = anim.rotate(obj.track0, 0, time * 90)
|
||||
obj.x = obj.x + rx
|
||||
obj.y = obj.y + ry</code></pre>
|
||||
|
||||
<h3>8-2. 2点間の距離で挙動を変える</h3>
|
||||
<pre><code>local d = anim.dist(obj.x, obj.y, 0, 0)
|
||||
obj.alpha = anim.clamp(255 - d, 0, 255)</code></pre>
|
||||
|
||||
<p>ベクトル・幾何系関数の一覧です。</p>
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>anim.len(x, y)</td><td>ベクトル (x, y) の長さ</td></tr>
|
||||
<tr><td>anim.dist(x1, y1, x2, y2)</td><td>2点間の距離</td></tr>
|
||||
<tr><td>anim.dot(x1, y1, x2, y2)</td><td>2ベクトルの内積</td></tr>
|
||||
<tr><td>anim.normalize(x, y)</td><td>正規化した方向ベクトル (Tuple で返却)</td></tr>
|
||||
<tr><td>anim.polar(r, a)</td><td>半径 r・角度 a(度) から移動量 (x, y)</td></tr>
|
||||
<tr><td>anim.rotate(x, y, a)</td><td>(x, y) を a(度) 回転させた座標</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="noise">9. anim ノイズ・乱数</h2>
|
||||
|
||||
<h3>9-1. 安定した乱数で個体差をつける</h3>
|
||||
<p>
|
||||
<code>anim.rand</code> はシード引数に基づく決定的な乱数です。レイヤー番号をシードにすると
|
||||
オブジェクトごとに異なる固定値が得られます。
|
||||
</p>
|
||||
<pre><code>local offset = anim.rand(-50, 50, obj.layer)
|
||||
obj.x = obj.x + offset</code></pre>
|
||||
|
||||
<h3>9-2. ノイズで揺らぐ不透明度</h3>
|
||||
<pre><code>obj.alpha = anim.noise(time, obj.layer, 0) * 255</code></pre>
|
||||
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>anim.noise(x, y, z)</td><td>1~3次元の滑らかなノイズ (0.0~1.0)</td></tr>
|
||||
<tr><td>anim.rand(min, max, s)</td><td>シード s に基づく安定した乱数</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="animcolor">10. anim 色</h2>
|
||||
|
||||
<h3>10-1. 時間で色相を回す (虹色)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>anim.hsv_to_rgb(h, s, v)</td><td>HSV (色相0~360, 彩度0~1, 明度0~1) を RGB に変換</td></tr>
|
||||
<tr><td>anim.rgb_to_hsv(r, g, b)</td><td>RGB (0~255) を HSV に変換</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="const">11. anim 定数</h2>
|
||||
<table border="1">
|
||||
<tr><th>定数</th><th>説明</th></tr>
|
||||
<tr><td>anim.tau</td><td>円周率の2倍 (math.pi * 2)</td></tr>
|
||||
<tr><td>anim.e</td><td>ネイピア数 (math.exp(1))</td></tr>
|
||||
<tr><td>anim.phi</td><td>黄金比 ((1 + math.sqrt(5)) / 2)</td></tr>
|
||||
<tr><td>anim.sqrt2</td><td>2の平方根 (math.sqrt(2))</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="getobject">12. 他オブジェクトの参照 (obj.getobject)</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.getobject(tag [, frame])</code> は、対象アイテムの「備考」欄に入力した文字列を
|
||||
タグとして、そのアイテムの描画情報を取得します。備考欄はプロパティエリアの上側にあります。
|
||||
第2引数 <code>frame</code> を指定すると、そのタイムラインフレーム時点の値を取得します
|
||||
(省略時は現在フレーム)。返り値は対象アイテム自身の座標・回転・拡大率であり、
|
||||
グループ制御・カメラ制御による変形は含みません。一致するアイテムが無い場合は
|
||||
<code>nil</code> を返します。同じタグのアイテムが複数あるときは、対象フレームで
|
||||
表示中のものを優先します。
|
||||
<code>obj.alpha</code> に値を代入すると不透明度が変わります。<code>time</code> はアイテム先頭からの経過秒数です。
|
||||
スクリプトはフレームごとに実行され、<code>obj</code> の値を書き換えると描画へ反映されます。
|
||||
</p>
|
||||
|
||||
<h3>12-1. 発射元の座標に合わせる</h3>
|
||||
<pre><code>local src = obj.getobject("routersys")
|
||||
if src then
|
||||
obj.x = src.x
|
||||
obj.y = src.y
|
||||
end</code></pre>
|
||||
<h2>できることの全体像</h2>
|
||||
|
||||
<h3>12-2. 発射元へ向かって移動する</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>12-3. 発射元へ向きながら移動する (ファンネル風)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>12-4. 一定速度で接近し、到達したら停止</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>12-5. 表示中のときだけ追従する</h3>
|
||||
<pre><code>local target = obj.getobject("routersys")
|
||||
if target and target.exist then
|
||||
obj.x = target.x
|
||||
obj.y = target.y
|
||||
end</code></pre>
|
||||
|
||||
<h3>12-6. 発射元の拡大率・回転・不透明度も引き継ぐ</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>12-7. 発射時の座標に固定する</h3>
|
||||
<p>
|
||||
弾の発射フレーム (弾アイテムの開始フレーム) は <code>timelineframe - frame</code> で
|
||||
求まります。そのフレーム時点の発射元座標を取得すれば、発射元が動いても弾の原点は
|
||||
発射位置に固定されます。
|
||||
</p>
|
||||
<pre><code>local fire = timelineframe - frame
|
||||
local src = obj.getobject("routersys", fire)
|
||||
if src then
|
||||
obj.x = src.x
|
||||
obj.y = src.y
|
||||
end</code></pre>
|
||||
|
||||
<p>返り値テーブルのメンバーは以下のとおりです。</p>
|
||||
<table border="1">
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td>exist</td><td>対象フレームが表示期間内か (boolean)</td></tr>
|
||||
<tr><td>x / y / z</td><td>描画位置 (ピクセル)</td></tr>
|
||||
<tr><td>zoom / sx / sy</td><td>拡大率 (1.0 で等倍)</td></tr>
|
||||
<tr><td>rx / ry / rz</td><td>X / Y / Z 軸回転角 (度)</td></tr>
|
||||
<tr><td>rxr / ryr / rzr</td><td>X / Y / Z 軸回転角 (ラジアン)</td></tr>
|
||||
<tr><td>alpha</td><td>不透明度 (0.0 ~ 255.0)</td></tr>
|
||||
<tr><td>layer</td><td>レイヤー番号</td></tr>
|
||||
<table>
|
||||
<tr><th>分野</th><th>主な API</th><th>参照</th></tr>
|
||||
<tr><td>座標・回転・拡大率・不透明度の制御</td><td><code>obj.x</code>, <code>obj.rz</code>, <code>obj.zoom</code>, <code>obj.alpha</code> ほか</td><td><a href="obj.html">obj</a></td></tr>
|
||||
<tr><td>時間・フレーム情報</td><td><code>time</code>, <code>frame</code>, <code>obj.t</code>, <code>timelineframe</code></td><td><a href="globals.html">グローバル変数</a></td></tr>
|
||||
<tr><td>アニメーション補間・波・ノイズ・色</td><td><code>anim.lerp</code>, <code>anim.ease_in_out</code>, <code>anim.noise</code>, <code>anim.hsv_to_rgb</code></td><td><a href="anim.html">anim</a></td></tr>
|
||||
<tr><td>他アイテムの参照</td><td><code>obj.getobject</code></td><td><a href="obj-functions.html">obj の関数</a></td></tr>
|
||||
<tr><td>ピクセル操作</td><td><code>obj.getpixel</code>, <code>obj.setpixel</code>, <code>obj.getpixeldata</code></td><td><a href="pixels.html">ピクセル操作</a></td></tr>
|
||||
<tr><td>図形・テキスト・画像・動画の読み込み</td><td><code>obj.load</code>, <code>obj.setfont</code></td><td><a href="obj-functions.html">obj の関数</a></td></tr>
|
||||
<tr><td>他エフェクトの適用・描画</td><td><code>obj.effect</code>, <code>obj.draw</code>, <code>obj.drawpoly</code></td><td><a href="obj-functions.html">obj の関数</a></td></tr>
|
||||
<tr><td>シーン・環境情報</td><td><code>scene.width</code>, <code>ymm4.is_saving</code></td><td><a href="scene-ymm4.html">scene / ymm4</a></td></tr>
|
||||
<tr><td>パラメータ UI の定義</td><td><code>--track@</code>, <code>--check@</code>, <code>--color@</code>, <code>--dialog:</code></td><td><a href="directives.html">パラメータ指定子</a></td></tr>
|
||||
<tr><td>高速化エンジンの選択</td><td><code>--!native</code>, <code>--!cpu</code>, <code>--!gpu</code></td><td><a href="engines.html">エンジンと高速化</a></td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="pixel">13. ピクセル操作</h2>
|
||||
|
||||
<p>
|
||||
ピクセル操作は実際の入力画像へアクセスするため、初回アクセス時に画像データの
|
||||
転送が発生します。座標は画像の左上を (0, 0) とし、右・下方向が正です。
|
||||
取得値はストレートアルファ相当です。
|
||||
</p>
|
||||
|
||||
<h3>13-1. getpixel / setpixel で赤成分を反転</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>13-2. getpixeldata でグレースケール (高速)</h3>
|
||||
<p>
|
||||
<code>obj.getpixeldata()</code> はピクセルへ直接アクセスできるプロキシを返します。
|
||||
インデックスは 1 始まりで、チャンネルは R, G, B, A の繰り返しです。
|
||||
<code>pixel(x, y)</code> の R チャンネルのインデックスは <code>(y * obj.w + x) * 4 + 1</code> です。
|
||||
</p>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>13-3. 中心からの距離でフェード (円形ビネット)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<p>
|
||||
<code>obj.putpixeldata()</code> は AviUtl との互換性のために存在しますが、
|
||||
このプラグインでは変更が自動的に反映されるため呼び出す必要はありません (no-op)。
|
||||
</p>
|
||||
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>戻り値</th><th>説明</th></tr>
|
||||
<tr><td>obj.getpixel(x, y)</td><td>r, g, b, a</td><td>指定座標のピクセルを取得 (各成分 0~255)</td></tr>
|
||||
<tr><td>obj.setpixel(x, y, r, g, b [, a])</td><td>なし</td><td>指定座標へ書き込み (a 既定 255)</td></tr>
|
||||
<tr><td>obj.getpixeldata()</td><td>PixelDataProxy</td><td>全ピクセルへの直接アクセスプロキシ</td></tr>
|
||||
<tr><td>obj.putpixeldata()</td><td>なし</td><td>互換用の空実装</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="scene">14. シーン情報 (scene)</h2>
|
||||
|
||||
<h3>14-1. シーンサイズに対する相対配置</h3>
|
||||
<pre><code>obj.x = scene.cx * obj.track0 / 100</code></pre>
|
||||
|
||||
<table border="1">
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td>scene.width</td><td>シーンの横解像度 (ピクセル)</td></tr>
|
||||
<tr><td>scene.height</td><td>シーンの縦解像度 (ピクセル)</td></tr>
|
||||
<tr><td>scene.cx</td><td>横解像度の半分 (= scene.width / 2)</td></tr>
|
||||
<tr><td>scene.cy</td><td>縦解像度の半分 (= scene.height / 2)</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="ymm4">15. 環境・メタ情報 (ymm4)</h2>
|
||||
|
||||
<h3>15-1. グループ内のインデックスで時間差をつける</h3>
|
||||
<pre><code>local d = ymm4.group_index * 0.1
|
||||
local p = anim.duration(anim.delay(time, d), 0.5)
|
||||
obj.alpha = p * 255</code></pre>
|
||||
|
||||
<h3>15-2. グループ内の進行割合で配置をずらす</h3>
|
||||
<pre><code>obj.x = obj.x + ymm4.group_ratio * 400</code></pre>
|
||||
|
||||
<h3>15-3. 出力時のみ挙動を変える</h3>
|
||||
<pre><code>if ymm4.is_saving then
|
||||
obj.alpha = 255
|
||||
else
|
||||
obj.alpha = 128
|
||||
end</code></pre>
|
||||
|
||||
<table border="1">
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td>ymm4.group_index</td><td>グループ制御内の現在のインデックス (0始まり)</td></tr>
|
||||
<tr><td>ymm4.group_count</td><td>グループ制御内の総アイテム数</td></tr>
|
||||
<tr><td>ymm4.group_ratio</td><td>グループ内の進行割合 (group_index / group_count)</td></tr>
|
||||
<tr><td>ymm4.timeline_totalframe</td><td>タイムライン全体の総フレーム数</td></tr>
|
||||
<tr><td>ymm4.timeline_totaltime</td><td>タイムライン全体の総時間 (秒)</td></tr>
|
||||
<tr><td>ymm4.time_ratio</td><td>現在の再生位置の割合 (0.0 ~ 1.0)</td></tr>
|
||||
<tr><td>ymm4.is_saving</td><td>動画出力中のみ true</td></tr>
|
||||
<tr><td>ymm4.is_playing</td><td>再生中のみ true</td></tr>
|
||||
<tr><td>ymm4.is_paused</td><td>一時停止中のみ true</td></tr>
|
||||
<tr><td>ymm4.scene_id</td><td>現在のシーンを識別する文字列 (Guid)</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="globals">16. グローバル変数</h2>
|
||||
<p>以下の変数はスクリプトのグローバルスコープで直接参照できます (すべて読み取り専用)。</p>
|
||||
<table border="1">
|
||||
<tr><th>変数</th><th>説明</th></tr>
|
||||
<tr><td>time</td><td>オブジェクト基準の現在時間 (秒)。obj.time と同じ</td></tr>
|
||||
<tr><td>frame</td><td>オブジェクト基準の現在フレーム番号。obj.frame と同じ</td></tr>
|
||||
<tr><td>totalframe</td><td>オブジェクトの総フレーム数。obj.totalframe と同じ</td></tr>
|
||||
<tr><td>framerate</td><td>フレームレート (fps)。obj.framerate と同じ</td></tr>
|
||||
<tr><td>timelineframe</td><td>タイムライン先頭からの絶対フレーム番号</td></tr>
|
||||
<tr><td>timelinetime</td><td>タイムライン基準の現在時間 (秒)</td></tr>
|
||||
<tr><td>layer</td><td>配置されているレイヤー番号。obj.layer と同じ</td></tr>
|
||||
<tr><td>obj / scene / ymm4 / anim</td><td>各テーブル (本ページ参照)</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="stdlib">17. 標準ライブラリ</h2>
|
||||
<p>利用できる標準ライブラリは以下に限定されます。io, os, debug, ffi, require 等は使用できません。</p>
|
||||
|
||||
<h3>math</h3>
|
||||
<p>
|
||||
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
|
||||
</p>
|
||||
|
||||
<h3>string</h3>
|
||||
<p>
|
||||
format, len, sub, upper, lower, rep, reverse, find, match, gmatch, gsub, byte, char,
|
||||
dump, pack, unpack, packsize
|
||||
</p>
|
||||
|
||||
<h3>table</h3>
|
||||
<p>insert, remove, sort, concat, unpack, move</p>
|
||||
|
||||
<h3>bit32</h3>
|
||||
<p>
|
||||
band, bor, bxor, bnot, lshift, rshift, arshift, extract, replace, btest, countlz, countrz
|
||||
</p>
|
||||
|
||||
<h3>基本関数</h3>
|
||||
<p>
|
||||
type, tostring, tonumber, select, error, assert, print, ipairs, pairs, next, unpack,
|
||||
setmetatable, getmetatable, rawget, rawset, rawequal, rawlen, pcall, xpcall
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="reference">クイックリファレンス</h2>
|
||||
|
||||
<h3>obj (変更可能メンバー)</h3>
|
||||
<table border="1">
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td>obj.x / obj.y / obj.z</td><td>描画位置 (ピクセル)</td></tr>
|
||||
<tr><td>obj.ox / obj.oy / obj.oz</td><td>回転中心のオフセット (ピクセル)</td></tr>
|
||||
<tr><td>obj.zoom</td><td>拡大率 (sx と sy の平均、1.0 で等倍)</td></tr>
|
||||
<tr><td>obj.aspect</td><td>アスペクト比 (-1.0 ~ 1.0)</td></tr>
|
||||
<tr><td>obj.sx / obj.sy</td><td>X / Y 方向の独立拡大率</td></tr>
|
||||
<tr><td>obj.alpha</td><td>不透明度 (0.0 ~ 255.0)</td></tr>
|
||||
<tr><td>obj.rx / obj.ry / obj.rz</td><td>X / Y / Z 軸回転角 (度)</td></tr>
|
||||
<tr><td>obj.rxr / obj.ryr / obj.rzr</td><td>X / Y / Z 軸回転角 (ラジアン)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>obj (読み取り専用メンバー)</h3>
|
||||
<table border="1">
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td>obj.w / obj.h</td><td>入力画像の幅 / 高さ (ピクセル)</td></tr>
|
||||
<tr><td>obj.hw / obj.hh</td><td>幅 / 高さの半分</td></tr>
|
||||
<tr><td>obj.cx / obj.cy</td><td>画像中心 (= hw / hh)</td></tr>
|
||||
<tr><td>obj.cz / obj.sz</td><td>常に 0 / 常に 1</td></tr>
|
||||
<tr><td>obj.diagonal</td><td>対角線長 (sqrt(w^2 + h^2))</td></tr>
|
||||
<tr><td>obj.time / obj.frame</td><td>アイテム基準の経過時間 (秒) / フレーム</td></tr>
|
||||
<tr><td>obj.totalframe / obj.totaltime</td><td>アイテムの総フレーム数 / 総時間 (秒)</td></tr>
|
||||
<tr><td>obj.t</td><td>アイテム内の進行割合 (0.0 ~ 1.0)</td></tr>
|
||||
<tr><td>obj.framerate</td><td>フレームレート (fps)</td></tr>
|
||||
<tr><td>obj.layer</td><td>レイヤー番号</td></tr>
|
||||
<tr><td>obj.index / obj.num</td><td>グループ内のインデックス / 総数</td></tr>
|
||||
<tr><td>obj.track0 ~ obj.track3</td><td>エフェクトパネルの各トラックバーの値</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>obj 関数</h3>
|
||||
<table border="1">
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td>obj.getobject(tag [, frame])</td><td>他アイテムの描画情報を取得 (本ページ 12 章)</td></tr>
|
||||
<tr><td>obj.getpixel(x, y)</td><td>ピクセル取得</td></tr>
|
||||
<tr><td>obj.setpixel(x, y, r, g, b [, a])</td><td>ピクセル書き込み</td></tr>
|
||||
<tr><td>obj.getpixeldata()</td><td>ピクセル直接アクセスプロキシ</td></tr>
|
||||
<tr><td>obj.putpixeldata()</td><td>互換用の空実装</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>非対応・制限事項</h2>
|
||||
<ul>
|
||||
<li>AviUtl2 の obj.effect(), obj.draw(), obj.drawpoly(), obj.load() 等は非対応です。</li>
|
||||
<li>obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor() 等は非対応です。</li>
|
||||
<li>scene.set(), scene.get() 等は非対応です (scene.width / scene.height の読み取りのみ)。</li>
|
||||
<li>ファイルアクセス (require, dofile, io 等) は非対応です。</li>
|
||||
<li>スクリプトのタイムアウトは 5 秒です。無限ループに注意してください。</li>
|
||||
<li>--track@, --check@ 等のヘッダーディレクティブは非対応です (Track0 ~ Track3 のみ)。</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>
|
||||
Luaスクリプト for YMM4 / MIT License /
|
||||
<a href="https://github.com/routersys/YMM4-LuaScript">https://github.com/routersys/YMM4-LuaScript</a>
|
||||
</p>
|
||||
<div class="pager">
|
||||
<span></span>
|
||||
<a href="getting-started.html">導入と使い方 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>制限事項とトラブル | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>制限事項とトラブル</h1>
|
||||
|
||||
<h2>実行に関する制限</h2>
|
||||
|
||||
<ul>
|
||||
<li>タイムアウト 5 秒: 1 フレームのスクリプト実行が 5 秒を超えると中断され、そのフレームは
|
||||
元の映像のままになります。無限ループや極端に重い処理に注意してください。</li>
|
||||
<li>フレーム間で状態は保持されない: 組み込み以外のグローバル変数は毎フレームリセットされます。
|
||||
前フレームの計算結果を変数に貯めることはできません。時間変化は <code>time</code> や <code>obj.t</code> から計算します。</li>
|
||||
<li>ファイルアクセス不可: <code>require</code>・<code>dofile</code>・<code>io</code> などは使えません。</li>
|
||||
<li>使えない標準ライブラリ: <code>io</code>・<code>os</code>・<code>debug</code>・<code>coroutine</code>・
|
||||
<code>package</code>・<code>ffi</code> は無効です(<a href="stdlib.html">標準ライブラリ</a>)。</li>
|
||||
</ul>
|
||||
|
||||
<h2>乱数について</h2>
|
||||
|
||||
<p>
|
||||
<code>math.random</code> の結果はフレームごとに決まります。シードの仕組みは
|
||||
<a href="stdlib.html">標準ライブラリ</a>の <code>math</code> で説明しています。
|
||||
オブジェクトやフレームに対して安定した乱数が欲しいときは、
|
||||
<a href="anim.html"><code>anim.rand</code></a> や <code>anim.noise</code>、
|
||||
<a href="obj-functions.html"><code>obj.rand</code></a> を使ってください。
|
||||
</p>
|
||||
|
||||
<h2>非対応の機能</h2>
|
||||
|
||||
<ul>
|
||||
<li><code>scene.set()</code> や <code>scene.get()</code> はありません。<code>scene</code> は解像度の読み取りだけに対応します。</li>
|
||||
<li><code>obj.setanchor()</code> など、本ドキュメントに記載のない AviUtl 関数は対応していません。</li>
|
||||
<li><code>obj.effect</code> は、AviUtl/AviUtl2 互換マップに宣言したエフェクト名と、YMM4 に読み込まれている映像エフェクトの名前・キーワードを解決します。
|
||||
名前が見つからない・適用に失敗した場合は、そのフレームでは元の映像がそのまま使われます。
|
||||
互換マップが対応するエフェクト名の一覧は<a href="obj-functions.html">obj の関数</a>を参照してください。</li>
|
||||
</ul>
|
||||
|
||||
<h2>エラー表示</h2>
|
||||
|
||||
<p>
|
||||
構文エラー・実行時エラー・タイムアウトが起きると、スクリプトエディタの該当行に赤い波線で
|
||||
警告が表示されます。まずはエラーメッセージと行番号を確認してください。
|
||||
</p>
|
||||
|
||||
<h2>困ったときは</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>症状</th><th>確認すること</th></tr>
|
||||
<tr><td>スクリプトを書いても見た目が変わらない</td><td>値を <code>obj</code> に代入しているか(グローバル変数に入れても反映されません)。
|
||||
例: <code>obj.x = ...</code>。読み取り専用メンバーに代入していないか。</td></tr>
|
||||
<tr><td>トラックバーや色が表示されない</td><td>指定子や使用状況によって表示が決まります。<a href="directives.html">パラメータ指定子</a> の表示条件を確認してください。</td></tr>
|
||||
<tr><td>前のフレームの値が消える</td><td>仕様です。グローバル変数はフレーム間で保持されません。</td></tr>
|
||||
<tr><td>処理が中断される / フレームが描画されない</td><td>5 秒のタイムアウトに達している可能性があります。ループ回数を減らすか、
|
||||
ピクセル処理を <a href="engines.html">カーネルやネイティブ</a>に任せられる形にしてください。</td></tr>
|
||||
<tr><td><code>--!native</code> を指定しても速くならない</td><td>プラグインの隣に <code>native</code> フォルダが配置されていないと MoonSharp で実行されます。
|
||||
配置を確認してください(ログに一度だけ警告が出ます)。</td></tr>
|
||||
<tr><td>GPU でわずかに結果が違う</td><td>GPU カーネルは float32 精度です。厳密一致が必要なら CPU カーネルかネイティブを使ってください。</td></tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>
|
||||
Lua スクリプト for YMM4 / MIT License /
|
||||
<a href="https://github.com/routersys/YMM4-LuaScript">https://github.com/routersys/YMM4-LuaScript</a>
|
||||
</p>
|
||||
|
||||
<div class="pager">
|
||||
<a href="reference.html">← クイックリファレンス</a>
|
||||
<a href="index.html">概要 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,251 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Lua の基礎 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>Lua の基礎</h1>
|
||||
|
||||
<p>
|
||||
このページは、Lua をはじめて触る人向けの入門です。Lua スクリプトエフェクトで使える範囲に絞って、
|
||||
言語そのものの書き方を学びます。エンジンは Lua 5.2 互換の MoonSharp です。
|
||||
ファイル入出力やコルーチンなど一部の機能は使えません。詳しくは<a href="stdlib.html">標準ライブラリ</a>を参照してください。
|
||||
</p>
|
||||
|
||||
<h2>コメント</h2>
|
||||
|
||||
<p>
|
||||
Lua のコメントは <code>--</code> から行末までです。複数行コメントは <code>--[[</code> から <code>]]</code> までです。
|
||||
コメントは実行に影響しません。なお、行頭の <code>--track:</code> や <code>--!native</code> のような特定の書式は
|
||||
プラグインが解釈する<a href="directives.html">指定子</a>として扱われます。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>書き方</th><th>意味</th></tr>
|
||||
<tr><td><code>-- text</code></td><td>1 行コメント</td></tr>
|
||||
<tr><td><code>--[[ text ]]</code></td><td>複数行コメント</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>値と型</h2>
|
||||
|
||||
<p>Lua の値には次の型があります。スクリプトでよく使うのは数値・文字列・真偽値・テーブルです。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>型</th><th>例</th><th>説明</th></tr>
|
||||
<tr><td>nil</td><td><code>nil</code></td><td>値が無いことを表す。未定義の変数も nil</td></tr>
|
||||
<tr><td>boolean</td><td><code>true</code>, <code>false</code></td><td>真偽値。条件分岐で使う</td></tr>
|
||||
<tr><td>number</td><td><code>10</code>, <code>3.14</code>, <code>-0.5</code></td><td>数値。内部は倍精度浮動小数点</td></tr>
|
||||
<tr><td>string</td><td><code>"hello"</code>, <code>'abc'</code></td><td>文字列</td></tr>
|
||||
<tr><td>table</td><td><code>{1, 2, 3}</code></td><td>配列や連想配列に使う唯一の構造体</td></tr>
|
||||
<tr><td>function</td><td><code>function(x) return x end</code></td><td>関数も値として扱える</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
条件式で「偽」とみなされるのは <code>false</code> と <code>nil</code> だけです。
|
||||
<code>0</code> も <code>""</code>(空文字列)も「真」です。これは C や JavaScript と違うので注意してください。
|
||||
</div>
|
||||
|
||||
<h2>変数</h2>
|
||||
|
||||
<p>
|
||||
変数は <code>local</code> を付けて宣言します。<code>local</code> を付けるとそのブロック内だけで有効な
|
||||
ローカル変数になります。付けないとグローバル変数になります。スクリプトでは原則 <code>local</code> を使ってください。
|
||||
</p>
|
||||
|
||||
<pre><code>local a = 10
|
||||
local b = 20
|
||||
local sum = a + b
|
||||
obj.x = sum</code></pre>
|
||||
|
||||
<p>複数の変数を一度に宣言・代入できます。</p>
|
||||
|
||||
<pre><code>local x, y = 100, 200
|
||||
x, y = y, x</code></pre>
|
||||
|
||||
<div class="warn">
|
||||
このエフェクトでは、グローバル変数の状態はフレーム間で保持されません。
|
||||
毎フレーム独立に実行されるため、「前のフレームの値」を変数に貯めることはできません。
|
||||
</div>
|
||||
|
||||
<h2>演算子</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>分類</th><th>演算子</th></tr>
|
||||
<tr><td>算術</td><td><code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>%</code>(剰余) <code>^</code>(べき乗)</td></tr>
|
||||
<tr><td>比較</td><td><code>==</code> <code>~=</code>(等しくない) <code><</code> <code>></code> <code><=</code> <code>>=</code></td></tr>
|
||||
<tr><td>論理</td><td><code>and</code> <code>or</code> <code>not</code></td></tr>
|
||||
<tr><td>連結</td><td><code>..</code>(文字列の連結)</td></tr>
|
||||
<tr><td>長さ</td><td><code>#</code>(文字列やテーブルの長さ)</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<code>and</code> と <code>or</code> は値を返します。<code>a and b</code> は <code>a</code> が偽なら <code>a</code>、
|
||||
真なら <code>b</code> を返します。<code>a or b</code> は <code>a</code> が真なら <code>a</code>、偽なら <code>b</code> を返します。
|
||||
これを使うと既定値を簡潔に書けます。
|
||||
</p>
|
||||
|
||||
<pre><code>local amp = obj.track0
|
||||
local v = amp ~= 0 and amp or 50
|
||||
obj.x = obj.x + v</code></pre>
|
||||
|
||||
<h2>条件分岐</h2>
|
||||
|
||||
<pre><code>if obj.t < 0.5 then
|
||||
obj.alpha = 255
|
||||
elseif obj.t < 0.8 then
|
||||
obj.alpha = 128
|
||||
else
|
||||
obj.alpha = 0
|
||||
end</code></pre>
|
||||
|
||||
<p>三項演算子の代わりに <code>and</code> / <code>or</code> を使うのが定番です。</p>
|
||||
|
||||
<pre><code>obj.alpha = obj.check0 and 255 or 0</code></pre>
|
||||
|
||||
<h2>繰り返し</h2>
|
||||
|
||||
<h3>数値 for</h3>
|
||||
<p><code>for 変数 = 開始, 終了 [, 増分] do ... end</code> です。終了値も含みます。</p>
|
||||
|
||||
<pre><code>local total = 0
|
||||
for i = 1, 10 do
|
||||
total = total + i
|
||||
end</code></pre>
|
||||
|
||||
<p>ピクセル処理では 0 始まりで幅・高さ分ループするのが基本形です。</p>
|
||||
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>汎用 for(ipairs / pairs)</h3>
|
||||
<p>配列を順に走査するなら <code>ipairs</code> を、すべてのキーを走査するなら <code>pairs</code> を使います。</p>
|
||||
|
||||
<pre><code>local points = {10, 20, 30}
|
||||
local sum = 0
|
||||
for index, value in ipairs(points) do
|
||||
sum = sum + value
|
||||
end</code></pre>
|
||||
|
||||
<h3>while と repeat</h3>
|
||||
<pre><code>local i = 0
|
||||
while i < 5 do
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
local j = 0
|
||||
repeat
|
||||
j = j + 1
|
||||
until j >= 5</code></pre>
|
||||
|
||||
<div class="warn">
|
||||
ループの終了条件は必ず満たされるようにしてください。
|
||||
無限ループになると 5 秒で実行が打ち切られ、そのフレームは描画されません。
|
||||
</div>
|
||||
|
||||
<h2>関数</h2>
|
||||
|
||||
<p>関数は <code>function</code> で定義します。スクリプト内で定義した関数は入力補完にも出ます。</p>
|
||||
|
||||
<pre><code>local function ease(t)
|
||||
return t * t * (3 - 2 * t)
|
||||
end
|
||||
|
||||
obj.alpha = ease(obj.t) * 255</code></pre>
|
||||
|
||||
<h3>複数の戻り値</h3>
|
||||
<p>Lua の関数は複数の値を返せます。<code>anim.polar</code> など多くの組み込み関数がこれを使います。</p>
|
||||
|
||||
<pre><code>local function offset()
|
||||
return 10, -20
|
||||
end
|
||||
|
||||
local dx, dy = offset()
|
||||
obj.x = obj.x + dx
|
||||
obj.y = obj.y + dy</code></pre>
|
||||
|
||||
<h3>可変長引数</h3>
|
||||
<pre><code>local function sum(...)
|
||||
local total = 0
|
||||
for _, v in ipairs({...}) do
|
||||
total = total + v
|
||||
end
|
||||
return total
|
||||
end</code></pre>
|
||||
|
||||
<h2>テーブル</h2>
|
||||
|
||||
<p>テーブルは Lua で唯一の複合データ構造で、配列にも連想配列にも使えます。</p>
|
||||
|
||||
<h3>配列として</h3>
|
||||
<pre><code>local list = {5, 10, 15}
|
||||
local first = list[1]
|
||||
local count = #list</code></pre>
|
||||
|
||||
<div class="note">
|
||||
配列のインデックスは 1 始まりです。多くの言語と違って 0 ではありません。
|
||||
ただし <code>obj.getpixel(x, y)</code> の座標や、数値 for を 0 から回す処理は別物です。
|
||||
ピクセルデータプロキシのインデックスは 1 始まりです(<a href="pixels.html">ピクセル操作</a>)。
|
||||
</div>
|
||||
|
||||
<h3>連想配列として</h3>
|
||||
<pre><code>local config = { speed = 90, radius = 100 }
|
||||
obj.rz = time * config.speed</code></pre>
|
||||
|
||||
<h3>テーブル操作</h3>
|
||||
<p><code>table</code> ライブラリで挿入・削除・連結・並べ替えができます。</p>
|
||||
|
||||
<pre><code>local t = {}
|
||||
table.insert(t, 1)
|
||||
table.insert(t, 2)
|
||||
table.sort(t)
|
||||
local joined = table.concat(t, ",")</code></pre>
|
||||
|
||||
<h2>文字列</h2>
|
||||
|
||||
<p>文字列は <code>string</code> ライブラリで整形・検索できます。連結は <code>..</code> です。</p>
|
||||
|
||||
<pre><code>local label = string.format("%.1f", obj.t)
|
||||
local upper = string.upper("abc")
|
||||
local n = string.len(label)</code></pre>
|
||||
|
||||
<h2>標準で使える数学関数</h2>
|
||||
|
||||
<p><code>math</code> ライブラリに基本的な数学関数があります。よく使うものだけ挙げます。</p>
|
||||
|
||||
<pre><code>local r = math.sqrt(obj.x * obj.x + obj.y * obj.y)
|
||||
local angle = math.atan2(obj.y, obj.x)
|
||||
obj.rz = math.deg(angle)
|
||||
obj.zoom = math.max(0.1, 1 + math.sin(time))</code></pre>
|
||||
|
||||
<p>
|
||||
全関数の一覧は <a href="stdlib.html">標準ライブラリ</a> を参照してください。
|
||||
アニメーション向けの高度な補間や波・ノイズは <a href="anim.html">anim ライブラリ</a> にまとまっています。
|
||||
</p>
|
||||
|
||||
<h2>このエフェクト特有の注意点</h2>
|
||||
|
||||
<p>
|
||||
標準 Lua との違いとして、使える標準ライブラリの範囲、乱数の扱い、5 秒の実行時間制限などの制約があります。
|
||||
これらは<a href="limits.html">制限事項とトラブル</a>にまとめています。
|
||||
</p>
|
||||
|
||||
<div class="pager">
|
||||
<a href="getting-started.html">← 導入と使い方</a>
|
||||
<a href="stdlib.html">標準ライブラリ →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,348 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>obj の関数 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>obj の関数</h1>
|
||||
|
||||
<p>
|
||||
<code>obj</code> には値だけでなく関数も用意されています。他アイテムの参照、ピクセル操作、
|
||||
図形やテキストの生成、他エフェクトの適用などができます。座標などの値メンバーは
|
||||
<a href="obj.html">obj オブジェクト</a> を参照してください。
|
||||
</p>
|
||||
|
||||
<h2>obj.getobject — 他アイテムの参照</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.getobject(tag [, frame])</code> は、対象アイテムの「備考」欄に入力した文字列を <code>tag</code> として、
|
||||
そのアイテムの描画情報を取得します。備考欄はプロパティエリアの上側にあります。
|
||||
第 2 引数 <code>frame</code> を指定すると、そのタイムラインフレーム時点の値を取得します(省略時は現在フレーム)。
|
||||
一致するアイテムが無い場合は <code>nil</code> を返します。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
返り値は対象アイテム自身の座標・回転・拡大率であり、グループ制御・カメラ制御による変形は含みません。
|
||||
同じタグのアイテムが複数あるときは、対象フレームで表示中のものが優先されます。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>exist</code></td><td>対象フレームが表示期間内か(boolean)</td></tr>
|
||||
<tr><td><code>x</code> / <code>y</code> / <code>z</code></td><td>描画位置(ピクセル)</td></tr>
|
||||
<tr><td><code>zoom</code> / <code>sx</code> / <code>sy</code></td><td>拡大率(1.0 で等倍)。<code>sx</code>・<code>sy</code> は <code>zoom</code> と同じ値</td></tr>
|
||||
<tr><td><code>rz</code> / <code>rzr</code></td><td>Z 軸回転角(度 / ラジアン)</td></tr>
|
||||
<tr><td><code>rx</code> / <code>ry</code> / <code>rxr</code> / <code>ryr</code></td><td>常に 0(X・Y 軸回転は取得しません)</td></tr>
|
||||
<tr><td><code>alpha</code></td><td>不透明度(0.0 ~ 255.0)</td></tr>
|
||||
<tr><td><code>layer</code></td><td>レイヤー番号</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>発射元の座標に合わせる</h3>
|
||||
<pre><code>local src = obj.getobject("routersys")
|
||||
if src then
|
||||
obj.x = src.x
|
||||
obj.y = src.y
|
||||
end</code></pre>
|
||||
|
||||
<h3>発射元へ向かって移動する</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>表示中のときだけ追従する</h3>
|
||||
<pre><code>local target = obj.getobject("routersys")
|
||||
if target and target.exist then
|
||||
obj.x = target.x
|
||||
obj.y = target.y
|
||||
end</code></pre>
|
||||
|
||||
<h3>発射時の座標に固定する</h3>
|
||||
<p>
|
||||
弾の発射フレーム(弾アイテムの開始フレーム)は <code>timelineframe - frame</code> で求まります。
|
||||
そのフレーム時点の発射元座標を取得すれば、発射元が動いても原点は発射位置に固定されます。
|
||||
</p>
|
||||
<pre><code>local fire = timelineframe - frame
|
||||
local src = obj.getobject("routersys", fire)
|
||||
if src then
|
||||
obj.x = src.x
|
||||
obj.y = src.y
|
||||
end</code></pre>
|
||||
|
||||
<h2>ピクセル操作</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.getpixel</code> / <code>obj.setpixel</code> / <code>obj.getpixeldata</code> は画像を直接読み書きします。
|
||||
座標・チャンネル・アルファの扱いといった詳細は <a href="pixels.html">ピクセル操作</a> を参照してください。
|
||||
ここでは関数の概要だけ示します。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>戻り値</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.getpixel(x, y)</code></td><td>r, g, b, a</td><td>指定座標のピクセルを取得(各成分 0 ~ 255)</td></tr>
|
||||
<tr><td><code>obj.setpixel(x, y, r, g, b [, a])</code></td><td>なし</td><td>指定座標へ書き込み(a 既定 255)</td></tr>
|
||||
<tr><td><code>obj.getpixeldata()</code></td><td>プロキシ</td><td>全ピクセルへ直接アクセスするプロキシを返す</td></tr>
|
||||
<tr><td><code>obj.putpixeldata()</code></td><td>なし</td><td>AviUtl 互換用の空実装(呼ぶ必要はない)</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>obj.rand — 整数の安定した乱数</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.rand(a, b [, seed [, frame]])</code> は <code>a</code> ~ <code>b</code> の範囲の整数を返します
|
||||
(端点を含みます)。同じ <code>seed</code> と <code>frame</code> の組では常に同じ値になります。
|
||||
<code>seed</code> の既定値は 0、<code>frame</code> の既定値は現在フレームです。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>戻り値</th><th>用途</th></tr>
|
||||
<tr><td><code>obj.rand(a, b)</code></td><td>整数</td><td>毎フレーム変わる乱数</td></tr>
|
||||
<tr><td><code>obj.rand(a, b, seed)</code></td><td>整数</td><td>シードで固定。レイヤー番号などを渡す</td></tr>
|
||||
<tr><td><code>obj.rand(a, b, seed, frame)</code></td><td>整数</td><td>フレームも固定して完全に決定的にする</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
小数を含む乱数や、ベクトル・色のゆらぎが欲しいときは <a href="anim.html"><code>anim.rand</code></a> や
|
||||
<code>anim.noise</code> が便利です。<code>obj.rand</code> は整数を返す AviUtl 互換の乱数です。
|
||||
</div>
|
||||
|
||||
<h2>obj.load — 図形・テキスト・画像・動画の読み込み</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.load(種類, ...)</code> は、対象の画像バッファを生成した内容で置き換えます。
|
||||
読み込み後は <code>obj.w</code> / <code>obj.h</code> などの寸法も更新されます。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>呼び出し</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.load("figure", name, color, size [, line [, aspect]])</code></td><td>図形を生成。<code>color</code> は <code>0xRRGGBB</code>、<code>size</code> は大きさ(px)、<code>line</code> は 0 以下で塗りつぶし・正で輪郭の太さ、<code>aspect</code> は -1.0 ~ 1.0</td></tr>
|
||||
<tr><td><code>obj.load("text", str)</code></td><td>文字列を描画。フォントは <code>obj.setfont</code> の設定を使う</td></tr>
|
||||
<tr><td><code>obj.load("image", path)</code></td><td>画像ファイルを読み込む</td></tr>
|
||||
<tr><td><code>obj.load("movie", path [, time])</code></td><td>動画の指定時刻のフレームを読み込む(既定は現在時刻)</td></tr>
|
||||
</table>
|
||||
|
||||
<p><code>obj.load("figure", ...)</code> で指定できる図形名は次のとおりです。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>図形</th><th>名前</th></tr>
|
||||
<tr><td>円・楕円</td><td><code>円</code> / <code>楕円</code> / <code>circle</code> / <code>ellipse</code></td></tr>
|
||||
<tr><td>三角形</td><td><code>三角形</code> / <code>triangle</code></td></tr>
|
||||
<tr><td>五角形</td><td><code>五角形</code> / <code>pentagon</code></td></tr>
|
||||
<tr><td>六角形</td><td><code>六角形</code> / <code>hexagon</code></td></tr>
|
||||
<tr><td>星形</td><td><code>星形</code> / <code>star</code></td></tr>
|
||||
<tr><td>四角形</td><td>上記以外の名前(既定)</td></tr>
|
||||
</table>
|
||||
|
||||
<pre><code>obj.load("figure", "star", 0xFFCC00, 200, 0, 0)</code></pre>
|
||||
|
||||
<h2>obj.setfont — フォント設定</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.setfont(name [, size [, type [, color]]])</code> は、続く <code>obj.load("text", ...)</code> で使う
|
||||
フォントを設定します。<code>type</code> はビットフラグで、ビット 0 が太字、ビット 1 が斜体です
|
||||
(太字+斜体は 3)。既定の大きさは 34、既定色は <code>0xFFFFFF</code> です。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.setfont("Yu Gothic UI", 48, 1, 0xFFFFFF)
|
||||
obj.load("text", "サンプル")</code></pre>
|
||||
|
||||
<h2>AviUtl 互換の描画・効果関数(上級)</h2>
|
||||
|
||||
<p>
|
||||
次の関数は AviUtl のスクリプト制御に近い使い勝手で用意されています。
|
||||
<code>obj.effect</code> は AviUtl/AviUtl2 のエフェクト名とパラメータ名で、対応する YMM4 の映像エフェクトを適用します。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.effect(name, key1, val1, ...)</code></td><td>AviUtl/AviUtl2 のエフェクト名で YMM4 の映像エフェクトを適用する。<code>key, val</code> の組は AviUtl のパラメータ名で指定し、互換マップを通じて YMM4 のプロパティへ変換される</td></tr>
|
||||
<tr><td><code>obj.draw([ox, oy, oz, zoom, alpha, aspect])</code></td><td>現在のバッファをオフセット・拡大率・不透明度を指定して描画する</td></tr>
|
||||
<tr><td><code>obj.drawpoly(x0,y0,z0, x1,y1,z1, x2,y2,z2, x3,y3,z3 [, u0,v0, ... ,u3,v3] [, alpha])</code></td><td>4 頂点のテクスチャ付きポリゴンを描画する。UV を省略すると画像全体を使う</td></tr>
|
||||
<tr><td><code>obj.copybuffer(dst, src)</code></td><td>バッファ間でコピーする。ID は <code>obj</code>(作業画像)・<code>tmp</code>・<code>cache:名前</code>。書き込み先が <code>obj</code> のときのみ作業画像を置き換える</td></tr>
|
||||
<tr><td><code>obj.setoption(name [, value])</code></td><td>オプションを設定する。<code>antialias</code> は <code>obj.draw</code> で参照される。<code>blend</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の合成モードを番号で指定する。番号は下記の「合成モード」を参照。<code>draw_state</code> は真偽値で、<code>true</code> なら作業画像を出力し、<code>false</code> なら入力をそのまま通す。<code>drawtarget</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画先を <code>"framebuffer"</code> と <code>"tempbuffer"</code> で切り替える。詳細は下記の「描画先」を参照</td></tr>
|
||||
<tr><td><code>obj.getoption(name)</code></td><td>設定したオプションを取得する</td></tr>
|
||||
<tr><td><code>obj.getvalue(name)</code></td><td><code>obj</code> の数値メンバーを名前で取得する</td></tr>
|
||||
<tr><td><code>obj.pixeloption(name [, value])</code></td><td>ピクセル処理向けのオプションを設定する</td></tr>
|
||||
<tr><td><code>obj.setanchor(name, count [, option, ...])</code></td><td>プレビュー上にドラッグ可能なアンカーポイントを表示し、その座標を <code>name</code> の Lua 変数へ格納する。設置数を返す。詳細は下記の「アンカーポイント」を参照</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>合成モード</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setoption("blend", 番号)</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画に合成モードを設定します。
|
||||
番号は YMM4 のプロパティパネルにある「合成モード」のドロップダウンと並び順が同じで、0 から始まります。
|
||||
範囲外の値や数値以外を指定したときは通常モードになります。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.setoption("blend", 3)
|
||||
obj.draw()</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>番号</th><th>合成モード</th></tr>
|
||||
<tr><td><code>0</code></td><td>通常</td></tr>
|
||||
<tr><td><code>1</code></td><td>ディザ合成</td></tr>
|
||||
<tr><td><code>2</code></td><td>比較(暗)</td></tr>
|
||||
<tr><td><code>3</code></td><td>乗算</td></tr>
|
||||
<tr><td><code>4</code></td><td>焼き込みカラー</td></tr>
|
||||
<tr><td><code>5</code></td><td>焼き込み(リニア)</td></tr>
|
||||
<tr><td><code>6</code></td><td>比較(明)</td></tr>
|
||||
<tr><td><code>7</code></td><td>スクリーン</td></tr>
|
||||
<tr><td><code>8</code></td><td>覆い焼きカラー</td></tr>
|
||||
<tr><td><code>9</code></td><td>覆い焼き(リニア) - 加算</td></tr>
|
||||
<tr><td><code>10</code></td><td>加算</td></tr>
|
||||
<tr><td><code>11</code></td><td>オーバーレイ</td></tr>
|
||||
<tr><td><code>12</code></td><td>ソフトライト</td></tr>
|
||||
<tr><td><code>13</code></td><td>ハードライト</td></tr>
|
||||
<tr><td><code>14</code></td><td>ビビッドライト</td></tr>
|
||||
<tr><td><code>15</code></td><td>リニアライト</td></tr>
|
||||
<tr><td><code>16</code></td><td>ピンライト</td></tr>
|
||||
<tr><td><code>17</code></td><td>ハードミックス</td></tr>
|
||||
<tr><td><code>18</code></td><td>差分</td></tr>
|
||||
<tr><td><code>19</code></td><td>除外</td></tr>
|
||||
<tr><td><code>20</code></td><td>減算</td></tr>
|
||||
<tr><td><code>21</code></td><td>除算</td></tr>
|
||||
<tr><td><code>22</code></td><td>色相</td></tr>
|
||||
<tr><td><code>23</code></td><td>彩度</td></tr>
|
||||
<tr><td><code>24</code></td><td>カラー</td></tr>
|
||||
<tr><td><code>25</code></td><td>輝度</td></tr>
|
||||
<tr><td><code>26</code></td><td>カラー比較(明)</td></tr>
|
||||
<tr><td><code>27</code></td><td>背景</td></tr>
|
||||
<tr><td><code>28</code></td><td>カラー比較(暗)</td></tr>
|
||||
<tr><td><code>29</code></td><td>削除</td></tr>
|
||||
<tr><td><code>30</code></td><td>背景でクリッピング</td></tr>
|
||||
<tr><td><code>31</code></td><td>重ならない部分のみ</td></tr>
|
||||
<tr><td><code>32</code></td><td>色反転マスク</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>描画先</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setoption("drawtarget", 先)</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画先を切り替えます。
|
||||
<code>"framebuffer"</code>(既定)ではフレームバッファへ合成します。
|
||||
<code>"tempbuffer"</code> では作業用の <code>tmp</code> バッファへその場で合成します。
|
||||
<code>obj.setoption("drawtarget", "tempbuffer", w, h)</code> の <code>w, h</code> は <code>tmp</code> バッファを初期化するサイズで、省略すると初期化しません。
|
||||
<code>tmp</code> へ描いた結果は <code>obj.copybuffer("obj", "tmp")</code> で作業画像へ戻せます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>tempbuffer</code> への合成は通常(ソースオーバー)で、<code>blend</code> は <code>framebuffer</code> への描画に適用されます。
|
||||
描画先の切り替えは両エンジンで動きます。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.setoption("drawtarget", "tempbuffer", obj.w, obj.h)
|
||||
obj.draw()
|
||||
obj.setoption("drawtarget", "framebuffer")
|
||||
obj.copybuffer("obj", "tmp")</code></pre>
|
||||
|
||||
<h3>アンカーポイント</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setanchor(name, count [, option, ...])</code> は、プレビュー上にドラッグ可能なアンカーポイントを表示します。
|
||||
ドラッグで調整した座標はプロジェクトへ保存され、<code>name</code> で指定した Lua 変数へ格納されます。
|
||||
変数は <code>pos={x0,y0,x1,y1,…}</code> の並びで、<code>"xyz"</code> を指定すると <code>{x0,y0,z0,x1,y1,z1,…}</code> になります。
|
||||
座標はオブジェクトの中心が原点です。個数は最大 32 個です。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>オプション</th><th>意味</th></tr>
|
||||
<tr><td><code>"line"</code></td><td>アンカーポイントを線で結ぶ</td></tr>
|
||||
<tr><td><code>"loop"</code></td><td>アンカーポイントを線で結び一周させる</td></tr>
|
||||
<tr><td><code>"star"</code></td><td>各アンカーポイントとオブジェクトの中心を線で結ぶ</td></tr>
|
||||
<tr><td><code>"arm"</code></td><td>オブジェクトの中心から各アンカーポイントへ順に線で結ぶ</td></tr>
|
||||
<tr><td><code>"xyz"</code></td><td>アンカーポイントを 3D 座標で扱う。既定は 2D</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
戻り値は設置したアンカーポイントの数です。両エンジンで動きます。
|
||||
<code>name</code> に <code>"track"</code> を指定するトラックバー連携は現在未対応で、<code>0</code> を返します。
|
||||
</p>
|
||||
|
||||
<pre><code>num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end</code></pre>
|
||||
|
||||
<h3>互換マップ</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.effect</code> は二段階で解決します。
|
||||
まず互換マップを参照し、AviUtl/AviUtl2 の名前として宣言したエフェクトは、
|
||||
パラメータ名の対応と値の変換を経て YMM4 のプロパティへ反映します。
|
||||
互換マップに宣言が無い名前は、YMM4 のエフェクト名やキーワードでそのまま解決します。
|
||||
たとえば <code>ウェーブクリッピング</code> のように、YMM4 やコミュニティのエフェクトを
|
||||
名前で呼ぶ使い方もそのまま動きます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
互換マップでは、パラメータの値を AviUtl と同じ尺度で渡すと、
|
||||
マップに定義した倍率とオフセットの変換を経て、YMM4 のプロパティへ反映します。
|
||||
たとえば <code>ぼかし</code> の <code>範囲</code> は YMM4 の <code>Blur</code> へ 0.5 倍で対応し、
|
||||
AviUtl と同じ見た目になります。
|
||||
この互換マップは、YMM4 自身が AviUtl の <code>.exo</code> へ書き出す変換を逆向きにたどって作っているため、
|
||||
往復しても結果が一致します。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
対象のエンジンは指定子 <code>--!aviutl</code> または <code>--!aviutl2</code> で切り替えます。
|
||||
指定子を書かないときは <code>--!aviutl</code> として扱います。
|
||||
各エントリは対応するエンジンを AviUtl・AviUtl2・両方のいずれかとして保持し、
|
||||
対象に一致するエントリだけを解決します。
|
||||
</p>
|
||||
|
||||
<pre><code>--!aviutl
|
||||
obj.effect("ぼかし", "範囲", 20)
|
||||
obj.effect("方向ブラー", "範囲", 16, "角度", 45)</code></pre>
|
||||
|
||||
<p>現在マップが宣言している AviUtl のエフェクト名は次のとおりです。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>エフェクト名</th><th>主なパラメータ</th></tr>
|
||||
<tr><td><code>ぼかし</code></td><td>範囲, サイズ固定</td></tr>
|
||||
<tr><td><code>境界ぼかし</code></td><td>範囲</td></tr>
|
||||
<tr><td><code>方向ブラー</code></td><td>範囲, 角度, サイズ固定</td></tr>
|
||||
<tr><td><code>放射ブラー</code></td><td>範囲, X, Y, サイズを固定</td></tr>
|
||||
<tr><td><code>閃光</code></td><td>範囲, X, Y, サイズを固定</td></tr>
|
||||
<tr><td><code>クロマキー</code></td><td>色相範囲, 境界補正</td></tr>
|
||||
<tr><td><code>クリッピング</code></td><td>上, 下, 左, 右, 中心の位置を変更</td></tr>
|
||||
<tr><td><code>斜めクリッピング</code></td><td>中心X, 中心Y, 角度, ぼかし, 幅</td></tr>
|
||||
<tr><td><code>領域拡張</code></td><td>上, 下, 左, 右</td></tr>
|
||||
<tr><td><code>座標</code></td><td>X, Y, Z</td></tr>
|
||||
<tr><td><code>回転</code></td><td>X, Y, Z</td></tr>
|
||||
<tr><td><code>リサイズ</code></td><td>拡大率, X, Y, 補間なし</td></tr>
|
||||
<tr><td><code>画像ループ</code></td><td>横回数, 縦回数</td></tr>
|
||||
<tr><td><code>極座標変換</code></td><td>中心幅, 渦巻</td></tr>
|
||||
<tr><td><code>グラデーション</code></td><td>強さ, 中心X, 中心Y, 角度, 幅</td></tr>
|
||||
<tr><td><code>単色化</code></td><td>強さ, 輝度を保持する</td></tr>
|
||||
<tr><td><code>縁取り</code></td><td>サイズ, ぼかし</td></tr>
|
||||
<tr><td><code>反転</code></td><td>—</td></tr>
|
||||
<tr><td><code>モザイク</code></td><td>サイズ</td></tr>
|
||||
<tr><td><code>ディスプレイスメントマップ</code></td><td>ぼかし</td></tr>
|
||||
<tr><td><code>動画ファイル合成</code></td><td>X, Y, 拡大率</td></tr>
|
||||
<tr><td><code>色調補正</code></td><td>明るさ, コントラスト, 色相, 輝度, 彩度</td></tr>
|
||||
<tr><td><code>色ずれ</code></td><td>ずれ幅, 角度, 強さ</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
対象のエフェクトが YMM4 やコミュニティプラグインに読み込まれていないとき、または適用に失敗したときは、
|
||||
そのフレームでは元の映像をそのまま使います。このときログへ警告を一度だけ出します。
|
||||
<code>色調補正</code> と <code>色ずれ</code> はコミュニティプラグインのエフェクトに対応します。
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<a href="obj.html">← obj オブジェクト</a>
|
||||
<a href="anim.html">anim ライブラリ →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>obj オブジェクト | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>obj オブジェクト</h1>
|
||||
|
||||
<p>
|
||||
<code>obj</code> は描画対象を表す中心的なテーブルです。座標・回転・拡大率・不透明度などの値を持ち、
|
||||
これらを書き換えると描画に反映されます。実行前に現在の値が入り、実行後に書き換えた値が読み戻されます。
|
||||
関数(ピクセル操作・読み込みなど)は <a href="obj-functions.html">obj の関数</a> にまとめています。
|
||||
</p>
|
||||
|
||||
<h2>変更可能なメンバー</h2>
|
||||
|
||||
<p>これらに代入すると描画が変わります。実行後にプラグインが読み戻します。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.x</code> / <code>obj.y</code> / <code>obj.z</code></td><td>描画位置(ピクセル)</td></tr>
|
||||
<tr><td><code>obj.ox</code> / <code>obj.oy</code> / <code>obj.oz</code></td><td>中心点のオフセット(ピクセル)。回転・拡大の基準がずれる</td></tr>
|
||||
<tr><td><code>obj.zoom</code></td><td>拡大率(sx と sy の平均、1.0 で等倍)</td></tr>
|
||||
<tr><td><code>obj.aspect</code></td><td>縦横比(-1.0 ~ 1.0)。正で横を縮小、負で縦を縮小</td></tr>
|
||||
<tr><td><code>obj.sx</code> / <code>obj.sy</code></td><td>X / Y 方向の独立した拡大率</td></tr>
|
||||
<tr><td><code>obj.alpha</code></td><td>不透明度(0.0 ~ 255.0)</td></tr>
|
||||
<tr><td><code>obj.rx</code> / <code>obj.ry</code> / <code>obj.rz</code></td><td>X / Y / Z 軸の回転角(度)</td></tr>
|
||||
<tr><td><code>obj.rxr</code> / <code>obj.ryr</code> / <code>obj.rzr</code></td><td>X / Y / Z 軸の回転角(ラジアン)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>拡大率(zoom / aspect と sx / sy)</h3>
|
||||
|
||||
<p>
|
||||
拡大率には 2 通りの指定方法があり、片方を変えるともう片方は自動で計算されます。
|
||||
入力時点では <code>zoom</code> は <code>sx</code> と <code>sy</code> の平均、
|
||||
<code>aspect</code> は <code>(sx - sy) / (sx + sy)</code> です。
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><code>sx</code> / <code>sy</code> を変更した場合 … その値がそのまま使われます。</li>
|
||||
<li><code>sx</code> / <code>sy</code> を変更せず <code>zoom</code> / <code>aspect</code> だけを変更した場合 …
|
||||
<code>sx = zoom * (1 + aspect)</code>、<code>sy = zoom * (1 - aspect)</code> として反映されます。</li>
|
||||
</ul>
|
||||
|
||||
<pre><code>obj.zoom = obj.zoom * 1.5
|
||||
|
||||
local s = math.sin(time * anim.tau * 2) * 0.2
|
||||
obj.sx = 1 + s
|
||||
obj.sy = 1 - s</code></pre>
|
||||
|
||||
<h3>回転(度とラジアン)</h3>
|
||||
|
||||
<p>
|
||||
回転は度(<code>rx</code> / <code>ry</code> / <code>rz</code>)とラジアン(<code>rxr</code> / <code>ryr</code> / <code>rzr</code>)の
|
||||
両方で指定できます。ラジアン版を変更した場合はラジアン版が優先され、
|
||||
変更しなければ度の値が使われます。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.rz = time * 90
|
||||
obj.rzr = time * anim.tau</code></pre>
|
||||
|
||||
<h2>読み取り専用メンバー</h2>
|
||||
|
||||
<p>入力画像の寸法や時間情報など、書き換えても反映されない値です。</p>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.w</code> / <code>obj.h</code></td><td>入力画像の幅 / 高さ(ピクセル)</td></tr>
|
||||
<tr><td><code>obj.hw</code> / <code>obj.hh</code></td><td>幅 / 高さの半分</td></tr>
|
||||
<tr><td><code>obj.cx</code> / <code>obj.cy</code></td><td>画像中心(幅 / 高さの半分に等しい)</td></tr>
|
||||
<tr><td><code>obj.cz</code></td><td>常に 0</td></tr>
|
||||
<tr><td><code>obj.sz</code></td><td>常に 1</td></tr>
|
||||
<tr><td><code>obj.diagonal</code></td><td>対角線の長さ(<code>sqrt(w^2 + h^2)</code>)</td></tr>
|
||||
<tr><td><code>obj.time</code></td><td>アイテム先頭からの経過時間(秒)</td></tr>
|
||||
<tr><td><code>obj.frame</code></td><td>現在フレーム番号</td></tr>
|
||||
<tr><td><code>obj.totalframe</code></td><td>総フレーム数</td></tr>
|
||||
<tr><td><code>obj.totaltime</code></td><td>総時間(秒)</td></tr>
|
||||
<tr><td><code>obj.t</code></td><td>アイテム内の進行割合(0.0 ~ 1.0、<code>frame / totalframe</code>)</td></tr>
|
||||
<tr><td><code>obj.framerate</code></td><td>フレームレート(fps)</td></tr>
|
||||
<tr><td><code>obj.layer</code></td><td>レイヤー番号</td></tr>
|
||||
<tr><td><code>obj.index</code></td><td>入力のインデックス</td></tr>
|
||||
<tr><td><code>obj.num</code></td><td>入力の総数</td></tr>
|
||||
<tr><td><code>obj.track0</code> ~ <code>obj.track3</code></td><td>トラックバーの値(数値)</td></tr>
|
||||
<tr><td><code>obj.check0</code> ~ <code>obj.check3</code></td><td>チェックボックスの値(真偽値)</td></tr>
|
||||
<tr><td><code>obj.slider0</code> ~ <code>obj.slider3</code></td><td>整数スライダーの値</td></tr>
|
||||
<tr><td><code>obj.text</code></td><td>テキスト入力欄の文字列</td></tr>
|
||||
<tr><td><code>obj.font</code></td><td>フォント選択欄のフォント名</td></tr>
|
||||
<tr><td><code>obj.dir</code></td><td>フォルダ選択欄のパス</td></tr>
|
||||
<tr><td><code>obj.file_video</code> ~ <code>obj.file_shader</code></td><td>各ファイル選択欄のパス</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
<code>obj.t</code> はアイテムの長さに対する進行割合なので、イージング関数の入力に最適です。
|
||||
一方 <code>time</code> は実時間(秒)なので、速度や周波数の指定に向いています。
|
||||
</div>
|
||||
|
||||
<h2>パラメータ(track / check)</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.track0</code> ~ <code>obj.track3</code> はパラメータパネルのトラックバーの値です。
|
||||
<code>obj.check0</code> ~ <code>obj.check3</code> はチェックボックスの値(true / false)です。
|
||||
名前・範囲・既定値・表示条件は <a href="directives.html">パラメータ指定子</a> で定義できます。
|
||||
</p>
|
||||
|
||||
<pre><code>local amp = obj.track0
|
||||
local freq = obj.track1
|
||||
obj.x = obj.x + math.sin(time * anim.tau * freq) * amp
|
||||
|
||||
if obj.check0 then
|
||||
obj.alpha = 255
|
||||
end</code></pre>
|
||||
|
||||
<h2>スライダーと文字列パラメータ</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.slider0</code> ~ <code>obj.slider3</code> は整数スライダーの値です。小数を含みません。
|
||||
表示範囲は <code>obj.slider0</code> が 1 ~ 10、<code>obj.slider1</code> が 0 ~ 100、
|
||||
<code>obj.slider2</code> が 0 ~ 1000、<code>obj.slider3</code> が -1000 ~ 1000 です。
|
||||
状態の切り替えなど、整数値の受け渡しに使えます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
文字列パラメータも参照できます。<code>obj.text</code> はテキスト入力欄の文字列、
|
||||
<code>obj.font</code> はフォント名、<code>obj.dir</code> はフォルダのパスです。
|
||||
ファイル選択欄は種類ごとに <code>obj.file_video</code> / <code>obj.file_audio</code> /
|
||||
<code>obj.file_image</code> / <code>obj.file_project</code> / <code>obj.file_mp4</code> /
|
||||
<code>obj.file_exo</code> / <code>obj.file_subtitle</code> / <code>obj.file_shader</code> で参照し、
|
||||
選択したファイルのパスを取得します。取得したパスは <code>obj.load</code> へ渡して画像や動画を読み込めます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
スライダーと文字列パラメータは、スクリプトがそれらを参照するとパラメータパネルへ表示されます。
|
||||
いずれのパラメータも MoonSharp とネイティブの両エンジンから参照できます。
|
||||
</p>
|
||||
|
||||
<pre><code>local mode = obj.slider0
|
||||
obj.load("image", obj.file_image)</code></pre>
|
||||
|
||||
<h2>よく使う例</h2>
|
||||
|
||||
<h3>中心を基準に振り子のように揺らす</h3>
|
||||
<pre><code>obj.oy = -obj.hh
|
||||
obj.rz = math.sin(time * anim.tau) * 30</code></pre>
|
||||
|
||||
<h3>画面サイズに対する相対配置</h3>
|
||||
<pre><code>obj.x = scene.cx * obj.track0 / 100</code></pre>
|
||||
|
||||
<div class="pager">
|
||||
<a href="globals.html">← グローバル変数</a>
|
||||
<a href="obj-functions.html">obj の関数 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>ピクセル操作 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>ピクセル操作</h1>
|
||||
|
||||
<p>
|
||||
入力画像を 1 ピクセルずつ読み書きできます。色の反転・グレースケール・ビネットなど、
|
||||
座標や色に基づく加工はピクセル操作で実現します。
|
||||
</p>
|
||||
|
||||
<h2>座標と色の約束</h2>
|
||||
|
||||
<ul>
|
||||
<li>座標は画像の左上を <code>(0, 0)</code> とし、右方向・下方向が正です。</li>
|
||||
<li>有効範囲は <code>0 ≦ x < obj.w</code>、<code>0 ≦ y < obj.h</code> です。
|
||||
範囲外を <code>getpixel</code> で読むと <code>(0, 0, 0, 0)</code> が返り、<code>setpixel</code> は無視されます。</li>
|
||||
<li>取得・設定する色は、アルファを乗算していないストレートな RGB です。各成分は 0 ~ 255 で、内部表現との変換は自動で行われます。</li>
|
||||
</ul>
|
||||
|
||||
<div class="note">
|
||||
ピクセル操作は実際の入力画像へアクセスするため、初回アクセス時に画像データの転送が発生します。
|
||||
転送は最初の 1 回だけです。
|
||||
</div>
|
||||
|
||||
<h2>getpixel / setpixel</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>戻り値</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.getpixel(x, y)</code></td><td>r, g, b, a</td><td>指定座標の色を取得(各成分 0 ~ 255)</td></tr>
|
||||
<tr><td><code>obj.setpixel(x, y, r, g, b [, a])</code></td><td>なし</td><td>指定座標へ書き込み(<code>a</code> 既定 255)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>赤成分を反転する</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>getpixeldata — 直接アクセス(高速)</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.getpixeldata()</code> は、全ピクセルへ直接アクセスできるプロキシを返します。
|
||||
1 ピクセルずつ関数を呼ぶ <code>getpixel</code> / <code>setpixel</code> より高速です。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>pd.width</code> / <code>pd.height</code></td><td>画像の幅 / 高さ</td></tr>
|
||||
<tr><td><code>pd:get(index)</code></td><td>指定インデックスのチャンネル値を取得(0 ~ 255)</td></tr>
|
||||
<tr><td><code>pd:set(index, value)</code></td><td>指定インデックスのチャンネル値を設定(0 ~ 255 にクランプ)</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
インデックスは 1 始まりで、各ピクセルにつき R, G, B, A の 4 チャンネルが順に並びます。
|
||||
座標 <code>(x, y)</code> の R チャンネルのインデックスは <code>(y * pd.width + x) * 4 + 1</code> です。
|
||||
続く +1, +2, +3 がそれぞれ G, B, A になります。
|
||||
</p>
|
||||
|
||||
<div class="note">
|
||||
プロキシのメンバーアクセスはコロン記法(<code>pd:get(i)</code> / <code>pd:set(i, v)</code>)で呼びます。
|
||||
幅・高さはドット記法(<code>pd.width</code> / <code>pd.height</code>)で読みます。
|
||||
</div>
|
||||
|
||||
<h3>グレースケール化</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>中心からの距離でフェード(円形ビネット)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>アルファの扱い</h2>
|
||||
|
||||
<p>
|
||||
A チャンネル(インデックス <code>base + 4</code>)を変更すると、不透明度が変わります。
|
||||
このとき RGB はストレートな色味を保ったまま再計算されます。アルファを 0 にすると、そのピクセルは透明になります。
|
||||
</p>
|
||||
|
||||
<h2>putpixeldata について</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.putpixeldata()</code> は AviUtl との互換のために存在しますが、このプラグインでは
|
||||
変更が自動的に反映されるため、呼び出す必要はありません(何もしません)。
|
||||
</p>
|
||||
|
||||
<h2>性能とエンジン</h2>
|
||||
|
||||
<p>
|
||||
ピクセル処理は重くなりがちです。このプラグインは <code>getpixel</code> / <code>setpixel</code> を含むスクリプトを
|
||||
自動的に高速なネイティブレーンへ振り分けます(利用できる場合)。さらに、二重ループで
|
||||
<code>getpixel</code> → 計算 → <code>setpixel</code> という決まった形のスクリプトは、CPU / GPU カーネルへ
|
||||
変換されてさらに高速に実行できます。詳しくは <a href="engines.html">エンジンと高速化</a> を参照してください。
|
||||
</p>
|
||||
|
||||
<div class="pager">
|
||||
<a href="scene-ymm4.html">← scene と ymm4</a>
|
||||
<a href="engines.html">エンジンと高速化 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>クイックリファレンス | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>クイックリファレンス</h1>
|
||||
|
||||
<p>すべての変数・関数・指定子を一覧でまとめます。詳細は各ページを参照してください。</p>
|
||||
|
||||
<h2>グローバル変数</h2>
|
||||
<table>
|
||||
<tr><th>変数</th><th>説明</th></tr>
|
||||
<tr><td><code>time</code></td><td>アイテム基準の経過時間(秒)</td></tr>
|
||||
<tr><td><code>frame</code></td><td>アイテム基準の現在フレーム</td></tr>
|
||||
<tr><td><code>totalframe</code></td><td>アイテムの総フレーム数</td></tr>
|
||||
<tr><td><code>framerate</code></td><td>フレームレート(fps)</td></tr>
|
||||
<tr><td><code>timelineframe</code></td><td>タイムライン先頭からの絶対フレーム</td></tr>
|
||||
<tr><td><code>timelinetime</code></td><td>タイムライン基準の時間(秒)</td></tr>
|
||||
<tr><td><code>layer</code></td><td>レイヤー番号</td></tr>
|
||||
<tr><td><code>color</code></td><td>Color パラメータの色(0xRRGGBB)</td></tr>
|
||||
<tr><td><code>obj</code> / <code>scene</code> / <code>anim</code> / <code>ymm4</code></td><td>各テーブル</td></tr>
|
||||
<tr><td><code>math</code> / <code>string</code> / <code>table</code> / <code>bit32</code></td><td>標準ライブラリ</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>obj(変更可能)</h2>
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.x</code> / <code>obj.y</code> / <code>obj.z</code></td><td>描画位置</td></tr>
|
||||
<tr><td><code>obj.ox</code> / <code>obj.oy</code> / <code>obj.oz</code></td><td>中心点オフセット</td></tr>
|
||||
<tr><td><code>obj.zoom</code></td><td>拡大率(sx と sy の平均)</td></tr>
|
||||
<tr><td><code>obj.aspect</code></td><td>縦横比(-1.0 ~ 1.0)</td></tr>
|
||||
<tr><td><code>obj.sx</code> / <code>obj.sy</code></td><td>独立した拡大率</td></tr>
|
||||
<tr><td><code>obj.alpha</code></td><td>不透明度(0.0 ~ 255.0)</td></tr>
|
||||
<tr><td><code>obj.rx</code> / <code>obj.ry</code> / <code>obj.rz</code></td><td>回転角(度)</td></tr>
|
||||
<tr><td><code>obj.rxr</code> / <code>obj.ryr</code> / <code>obj.rzr</code></td><td>回転角(ラジアン、優先)</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>obj(読み取り専用)</h2>
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.w</code> / <code>obj.h</code></td><td>入力画像の幅 / 高さ</td></tr>
|
||||
<tr><td><code>obj.hw</code> / <code>obj.hh</code></td><td>幅 / 高さの半分</td></tr>
|
||||
<tr><td><code>obj.cx</code> / <code>obj.cy</code></td><td>画像中心</td></tr>
|
||||
<tr><td><code>obj.cz</code> / <code>obj.sz</code></td><td>常に 0 / 常に 1</td></tr>
|
||||
<tr><td><code>obj.diagonal</code></td><td>対角線長</td></tr>
|
||||
<tr><td><code>obj.time</code> / <code>obj.frame</code></td><td>経過時間 / フレーム</td></tr>
|
||||
<tr><td><code>obj.totalframe</code> / <code>obj.totaltime</code></td><td>総フレーム数 / 総時間</td></tr>
|
||||
<tr><td><code>obj.t</code></td><td>進行割合(0.0 ~ 1.0)</td></tr>
|
||||
<tr><td><code>obj.framerate</code></td><td>フレームレート</td></tr>
|
||||
<tr><td><code>obj.layer</code></td><td>レイヤー番号</td></tr>
|
||||
<tr><td><code>obj.index</code> / <code>obj.num</code></td><td>入力のインデックス / 総数</td></tr>
|
||||
<tr><td><code>obj.track0</code> ~ <code>obj.track3</code></td><td>トラックバーの値</td></tr>
|
||||
<tr><td><code>obj.check0</code> ~ <code>obj.check3</code></td><td>チェックボックスの値</td></tr>
|
||||
<tr><td><code>obj.slider0</code> ~ <code>obj.slider3</code></td><td>整数スライダーの値</td></tr>
|
||||
<tr><td><code>obj.text</code> / <code>obj.font</code> / <code>obj.dir</code></td><td>テキスト、フォント名、フォルダパス</td></tr>
|
||||
<tr><td><code>obj.file_video</code> ~ <code>obj.file_shader</code></td><td>各ファイル選択欄のパス</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>obj 関数</h2>
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>obj.getobject(tag [, frame])</code></td><td>他アイテムの描画情報を取得</td></tr>
|
||||
<tr><td><code>obj.getpixel(x, y)</code></td><td>ピクセル取得</td></tr>
|
||||
<tr><td><code>obj.setpixel(x, y, r, g, b [, a])</code></td><td>ピクセル書き込み</td></tr>
|
||||
<tr><td><code>obj.getpixeldata()</code></td><td>ピクセル直接アクセスプロキシ</td></tr>
|
||||
<tr><td><code>obj.putpixeldata()</code></td><td>互換用の空実装</td></tr>
|
||||
<tr><td><code>obj.rand(a, b [, seed [, frame]])</code></td><td>整数の安定した乱数</td></tr>
|
||||
<tr><td><code>obj.load(種類, ...)</code></td><td>図形 / テキスト / 画像 / 動画の読み込み</td></tr>
|
||||
<tr><td><code>obj.setfont(name [, size [, type [, color]]])</code></td><td>フォント設定</td></tr>
|
||||
<tr><td><code>obj.effect(name, key, val, ...)</code></td><td>AviUtl/AviUtl2 互換マップ経由でエフェクトを適用</td></tr>
|
||||
<tr><td><code>obj.draw([ox, oy, oz, zoom, alpha, aspect])</code></td><td>バッファの描画</td></tr>
|
||||
<tr><td><code>obj.drawpoly(...)</code></td><td>4 頂点ポリゴンの描画</td></tr>
|
||||
<tr><td><code>obj.copybuffer(dst, src)</code></td><td>バッファのコピー</td></tr>
|
||||
<tr><td><code>obj.setoption(name [, value])</code> / <code>obj.getoption(name)</code></td><td>オプションの設定 / 取得</td></tr>
|
||||
<tr><td><code>obj.getvalue(name)</code></td><td>obj の数値メンバーを名前で取得</td></tr>
|
||||
<tr><td><code>obj.pixeloption(name [, value])</code></td><td>ピクセル処理オプション</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>anim(定数)</h2>
|
||||
<table>
|
||||
<tr><th>定数</th><th>説明</th></tr>
|
||||
<tr><td><code>anim.tau</code></td><td>math.pi * 2</td></tr>
|
||||
<tr><td><code>anim.e</code></td><td>ネイピア数</td></tr>
|
||||
<tr><td><code>anim.phi</code></td><td>黄金比</td></tr>
|
||||
<tr><td><code>anim.sqrt2</code></td><td>2 の平方根</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>anim(関数)</h2>
|
||||
<table>
|
||||
<tr><th>分類</th><th>関数</th></tr>
|
||||
<tr><td>補間・イージング</td><td><code>lerp, smoothstep, smootherstep, ease_in, ease_out, ease_in_out, elastic, back, bounce, step, bezier</code></td></tr>
|
||||
<tr><td>範囲・周期</td><td><code>clamp, map, norm, wrap, pingpong, sign, fract, oscillate, triangle, square, duration, delay</code></td></tr>
|
||||
<tr><td>ベクトル・幾何</td><td><code>len, dist, dot, normalize, polar, rotate</code></td></tr>
|
||||
<tr><td>ノイズ・乱数</td><td><code>noise, rand</code></td></tr>
|
||||
<tr><td>色変換</td><td><code>hsv_to_rgb, rgb_to_hsv</code></td></tr>
|
||||
</table>
|
||||
|
||||
<h2>scene</h2>
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>scene.width</code> / <code>scene.height</code></td><td>シーンの解像度</td></tr>
|
||||
<tr><td><code>scene.cx</code> / <code>scene.cy</code></td><td>解像度の半分</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>ymm4</h2>
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>ymm4.group_index</code> / <code>group_count</code> / <code>group_ratio</code></td><td>グループ制御の情報</td></tr>
|
||||
<tr><td><code>ymm4.timeline_totalframe</code> / <code>timeline_totaltime</code></td><td>タイムライン全体の長さ</td></tr>
|
||||
<tr><td><code>ymm4.time_ratio</code></td><td>再生位置の割合</td></tr>
|
||||
<tr><td><code>ymm4.is_saving</code> / <code>is_playing</code> / <code>is_paused</code></td><td>再生・出力状態</td></tr>
|
||||
<tr><td><code>ymm4.scene_id</code></td><td>シーン識別子(GUID)</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>指定子</h2>
|
||||
<table>
|
||||
<tr><th>指定子</th><th>説明</th></tr>
|
||||
<tr><td><code>--track0:</code> ~ <code>--track3:</code></td><td>トラックバーの定義</td></tr>
|
||||
<tr><td><code>--check0:</code> ~ <code>--check3:</code></td><td>チェックボックスの定義</td></tr>
|
||||
<tr><td><code>--color:</code></td><td>色パラメータの既定色</td></tr>
|
||||
<tr><td><code>--param:</code> / <code>--dialog:</code></td><td>本文先頭への宣言の追加</td></tr>
|
||||
<tr><td><code>--!moonsharp</code> / <code>--!native</code> / <code>--!cpu</code> / <code>--!gpu</code></td><td>実行エンジンの指定</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="pager">
|
||||
<a href="samples.html">← サンプル集</a>
|
||||
<a href="limits.html">制限事項とトラブル →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>サンプル集 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>サンプル集</h1>
|
||||
|
||||
<p>
|
||||
各サンプルはエフェクトのスクリプト欄にそのまま貼り付けて使えます。
|
||||
<code>Track0</code> ~ <code>Track3</code> はパラメータパネルのトラックバーで調整できます。
|
||||
使われている変数・関数の意味は各リファレンスページを参照してください。
|
||||
</p>
|
||||
|
||||
<h2>基本</h2>
|
||||
|
||||
<h3>フェードイン(既定スクリプト)</h3>
|
||||
<pre><code>obj.alpha = math.min(time * 255, 255)</code></pre>
|
||||
|
||||
<h3>フェードアウト</h3>
|
||||
<pre><code>obj.alpha = math.max((obj.totalframe - obj.frame) / obj.framerate * 255, 0)</code></pre>
|
||||
|
||||
<h3>Track0 で不透明度を制御</h3>
|
||||
<pre><code>obj.alpha = obj.track0</code></pre>
|
||||
|
||||
<h3>時間に応じて回転</h3>
|
||||
<pre><code>obj.rz = time * 90</code></pre>
|
||||
|
||||
<h3>Track0 でズームを制御</h3>
|
||||
<pre><code>obj.zoom = obj.zoom * (1 + obj.track0 / 100)</code></pre>
|
||||
|
||||
<h2>座標と動き</h2>
|
||||
|
||||
<h3>左右の揺れ</h3>
|
||||
<p>Track0 を振幅、Track1 を 1 秒あたりの周波数として使います。振幅の単位はピクセルです。</p>
|
||||
<pre><code>local amp = obj.track0
|
||||
local freq = obj.track1
|
||||
obj.x = obj.x + math.sin(time * anim.tau * freq) * amp</code></pre>
|
||||
|
||||
<h3>円運動</h3>
|
||||
<pre><code>local r = obj.track0
|
||||
local dx, dy = anim.polar(r, time * 90)
|
||||
obj.x = obj.x + dx
|
||||
obj.y = obj.y + dy</code></pre>
|
||||
|
||||
<h3>バウンド(跳ねる)</h3>
|
||||
<pre><code>local h = obj.track0
|
||||
obj.y = obj.y - anim.bounce(anim.pingpong(time, 1)) * h</code></pre>
|
||||
|
||||
<h3>ゆらぎ(ノイズによる手ぶれ風)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>回転</h2>
|
||||
|
||||
<h3>度とラジアン</h3>
|
||||
<pre><code>obj.rzr = time * anim.tau</code></pre>
|
||||
|
||||
<h3>加速しながら回転</h3>
|
||||
<pre><code>obj.rz = anim.ease_in(obj.t) * 360</code></pre>
|
||||
|
||||
<h2>拡大・変形</h2>
|
||||
|
||||
<h3>弾むように登場(スケールイン)</h3>
|
||||
<pre><code>local p = anim.duration(time, 0.3)
|
||||
obj.zoom = obj.zoom * anim.elastic(p)</code></pre>
|
||||
|
||||
<h3>ぷにぷに(独立スケール)</h3>
|
||||
<pre><code>local s = math.sin(time * anim.tau * 2) * 0.2
|
||||
obj.sx = 1 + s
|
||||
obj.sy = 1 - s</code></pre>
|
||||
|
||||
<h2>不透明度・フェード</h2>
|
||||
|
||||
<h3>遅延フェードイン</h3>
|
||||
<pre><code>local p = anim.duration(anim.delay(time, 0.5), 1)
|
||||
obj.alpha = p * 255</code></pre>
|
||||
|
||||
<h3>点滅(矩形波)</h3>
|
||||
<pre><code>obj.alpha = anim.square(time, 4) * 255</code></pre>
|
||||
|
||||
<h3>滑らかな明滅(正弦波)</h3>
|
||||
<pre><code>obj.alpha = anim.oscillate(time, 64, 255, 1)</code></pre>
|
||||
|
||||
<h2>イージングと範囲</h2>
|
||||
|
||||
<h3>2 点間をイージングで移動</h3>
|
||||
<pre><code>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)</code></pre>
|
||||
|
||||
<h3>行き過ぎてから戻る</h3>
|
||||
<pre><code>obj.x = obj.x + anim.back(obj.t) * 200</code></pre>
|
||||
|
||||
<h3>しきい値で切り替え</h3>
|
||||
<pre><code>obj.alpha = anim.smoothstep(0, 0.5, obj.t) * 255</code></pre>
|
||||
|
||||
<h2>他オブジェクトの参照</h2>
|
||||
|
||||
<h3>発射元へ向きながら移動する(ファンネル風)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>一定速度で接近し、到達したら停止</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>ピクセル操作</h2>
|
||||
|
||||
<h3>色の反転</h3>
|
||||
<pre><code>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, 255 - g, 255 - b, a)
|
||||
end
|
||||
end</code></pre>
|
||||
|
||||
<h3>グレースケール(高速)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h3>時間で色相を回す(虹色)</h3>
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<h2>図形・テキスト</h2>
|
||||
|
||||
<h3>星形を生成して回す</h3>
|
||||
<pre><code>obj.load("figure", "star", 0xFFCC00, 200, 0, 0)
|
||||
obj.rz = time * 90</code></pre>
|
||||
|
||||
<h3>テキストを生成する</h3>
|
||||
<pre><code>obj.setfont("Yu Gothic UI", 48, 1, 0xFFFFFF)
|
||||
obj.load("text", "サンプル")</code></pre>
|
||||
|
||||
<h2>環境に応じた制御</h2>
|
||||
|
||||
<h3>グループ内のインデックスで時間差をつける</h3>
|
||||
<pre><code>local d = ymm4.group_index * 0.1
|
||||
local p = anim.duration(anim.delay(time, d), 0.5)
|
||||
obj.alpha = p * 255</code></pre>
|
||||
|
||||
<h3>出力時のみ挙動を変える</h3>
|
||||
<pre><code>if ymm4.is_saving then
|
||||
obj.alpha = 255
|
||||
else
|
||||
obj.alpha = 128
|
||||
end</code></pre>
|
||||
|
||||
<div class="pager">
|
||||
<a href="directives.html">← パラメータ指定子</a>
|
||||
<a href="reference.html">クイックリファレンス →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>scene と ymm4 | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>scene と ymm4</h1>
|
||||
|
||||
<p>
|
||||
<code>scene</code> はシーンの解像度を、<code>ymm4</code> はグループ・タイムライン・再生状態などの
|
||||
環境情報を提供します。どちらも読み取り専用です。
|
||||
</p>
|
||||
|
||||
<h2>scene — シーン情報</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>説明</th></tr>
|
||||
<tr><td><code>scene.width</code></td><td>シーンの横解像度(ピクセル)</td></tr>
|
||||
<tr><td><code>scene.height</code></td><td>シーンの縦解像度(ピクセル)</td></tr>
|
||||
<tr><td><code>scene.cx</code></td><td>横解像度の半分(<code>scene.width / 2</code>)</td></tr>
|
||||
<tr><td><code>scene.cy</code></td><td>縦解像度の半分(<code>scene.height / 2</code>)</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
このプラグインで使える <code>scene</code> は解像度の読み取りのみです。
|
||||
AviUtl の <code>scene.set()</code> / <code>scene.get()</code> のような機能はありません。
|
||||
</div>
|
||||
|
||||
<h3>シーンサイズに対する相対配置</h3>
|
||||
<pre><code>obj.x = scene.cx * obj.track0 / 100</code></pre>
|
||||
|
||||
<h2>ymm4 — 環境・メタ情報</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>メンバー</th><th>型</th><th>説明</th></tr>
|
||||
<tr><td><code>ymm4.group_index</code></td><td>整数</td><td>グループ制御内の現在のインデックス(0 始まり)</td></tr>
|
||||
<tr><td><code>ymm4.group_count</code></td><td>整数</td><td>グループ制御内の総アイテム数</td></tr>
|
||||
<tr><td><code>ymm4.group_ratio</code></td><td>数値</td><td>グループ内の進行割合(<code>group_index / group_count</code>)</td></tr>
|
||||
<tr><td><code>ymm4.timeline_totalframe</code></td><td>整数</td><td>タイムライン全体の総フレーム数</td></tr>
|
||||
<tr><td><code>ymm4.timeline_totaltime</code></td><td>数値</td><td>タイムライン全体の総時間(秒)</td></tr>
|
||||
<tr><td><code>ymm4.time_ratio</code></td><td>数値</td><td>現在の再生位置の割合(0.0 ~ 1.0)</td></tr>
|
||||
<tr><td><code>ymm4.is_saving</code></td><td>真偽値</td><td>動画出力中のみ true</td></tr>
|
||||
<tr><td><code>ymm4.is_playing</code></td><td>真偽値</td><td>再生中のみ true</td></tr>
|
||||
<tr><td><code>ymm4.is_paused</code></td><td>真偽値</td><td>一時停止中のみ true</td></tr>
|
||||
<tr><td><code>ymm4.scene_id</code></td><td>文字列</td><td>現在のシーンを識別する文字列(GUID)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>グループ内のインデックスで時間差をつける</h3>
|
||||
<pre><code>local d = ymm4.group_index * 0.1
|
||||
local p = anim.duration(anim.delay(time, d), 0.5)
|
||||
obj.alpha = p * 255</code></pre>
|
||||
|
||||
<h3>グループ内の進行割合で配置をずらす</h3>
|
||||
<pre><code>obj.x = obj.x + ymm4.group_ratio * 400</code></pre>
|
||||
|
||||
<h3>出力時のみ挙動を変える</h3>
|
||||
<pre><code>if ymm4.is_saving then
|
||||
obj.alpha = 255
|
||||
else
|
||||
obj.alpha = 128
|
||||
end</code></pre>
|
||||
|
||||
<div class="pager">
|
||||
<a href="anim.html">← anim ライブラリ</a>
|
||||
<a href="pixels.html">ピクセル操作 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<!-- created with free sitemap generation system www.sitemapxml.jp -->
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/</loc>
|
||||
<priority>1.0</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/engines.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/getting-started.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/lua-basics.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/obj.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/anim.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/pixels.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/samples.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/globals.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/obj-functions.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/scene-ymm4.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/directives.html</loc>
|
||||
<priority>0.8</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/limits.html</loc>
|
||||
<priority>0.7</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/index.html</loc>
|
||||
<priority>0.7</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/stdlib.html</loc>
|
||||
<priority>0.7</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://luascript.routersys.com/reference.html</loc>
|
||||
<priority>0.7</priority>
|
||||
<lastmod>2026-06-30T12:31:48+09:00</lastmod>
|
||||
</url>
|
||||
|
||||
</urlset>
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>標準ライブラリ | Lua スクリプト for YMM4</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="navtoggle" aria-label="メニュー">☰</button>
|
||||
<nav id="sidebar"></nav>
|
||||
<main>
|
||||
|
||||
<h1>標準ライブラリ</h1>
|
||||
|
||||
<p>
|
||||
利用できる標準ライブラリは次のモジュールに限定されています:
|
||||
基本関数・math・string・table・bit32、
|
||||
そしてテーブル反復子(<code>pairs</code> / <code>ipairs</code> / <code>next</code>)・メタテーブル・エラー処理です。
|
||||
</p>
|
||||
|
||||
<div class="warn">
|
||||
<code>io</code>・<code>os</code>・<code>debug</code>・<code>coroutine</code>・<code>package</code>・<code>require</code>・
|
||||
<code>dofile</code>・<code>ffi</code> などは使えません。ファイルアクセスは無効化されています。
|
||||
</div>
|
||||
|
||||
<h2>基本関数</h2>
|
||||
|
||||
<p>グローバルに直接呼べる関数です。</p>
|
||||
|
||||
<pre><code>type, tostring, tonumber, select, error, assert, print,
|
||||
ipairs, pairs, next, unpack,
|
||||
setmetatable, getmetatable, rawget, rawset, rawequal, rawlen,
|
||||
pcall, xpcall</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>type(v)</code></td><td>値の型名を文字列で返す</td></tr>
|
||||
<tr><td><code>tostring(v)</code></td><td>文字列へ変換</td></tr>
|
||||
<tr><td><code>tonumber(v [, base])</code></td><td>数値へ変換。変換できなければ nil</td></tr>
|
||||
<tr><td><code>select(n, ...)</code></td><td>可変長引数の n 番目以降、または <code>"#"</code> で個数</td></tr>
|
||||
<tr><td><code>error(msg)</code></td><td>エラーを発生させる</td></tr>
|
||||
<tr><td><code>assert(v [, msg])</code></td><td>v が偽ならエラー</td></tr>
|
||||
<tr><td><code>pcall(f, ...)</code></td><td>f を保護モードで呼び、成否と結果を返す</td></tr>
|
||||
<tr><td><code>xpcall(f, handler, ...)</code></td><td>エラーハンドラ付きの保護呼び出し</td></tr>
|
||||
<tr><td><code>ipairs(t)</code> / <code>pairs(t)</code></td><td>テーブルの反復子</td></tr>
|
||||
<tr><td><code>setmetatable</code> / <code>getmetatable</code></td><td>メタテーブルの設定・取得</td></tr>
|
||||
<tr><td><code>rawget</code> / <code>rawset</code> / <code>rawequal</code> / <code>rawlen</code></td><td>メタメソッドを介さない素の操作</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>math</h2>
|
||||
|
||||
<pre><code>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</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>関数 / 定数</th><th>説明</th></tr>
|
||||
<tr><td><code>math.pi</code></td><td>円周率</td></tr>
|
||||
<tr><td><code>math.huge</code></td><td>正の無限大</td></tr>
|
||||
<tr><td><code>math.abs(x)</code></td><td>絶対値</td></tr>
|
||||
<tr><td><code>math.floor(x)</code> / <code>math.ceil(x)</code></td><td>切り捨て / 切り上げ</td></tr>
|
||||
<tr><td><code>math.min(...)</code> / <code>math.max(...)</code></td><td>最小 / 最大</td></tr>
|
||||
<tr><td><code>math.sqrt(x)</code></td><td>平方根</td></tr>
|
||||
<tr><td><code>math.sin/cos/tan(x)</code></td><td>三角関数(引数はラジアン)</td></tr>
|
||||
<tr><td><code>math.atan(x)</code> / <code>math.atan2(y, x)</code></td><td>逆正接</td></tr>
|
||||
<tr><td><code>math.deg(x)</code> / <code>math.rad(x)</code></td><td>ラジアン↔度</td></tr>
|
||||
<tr><td><code>math.exp(x)</code> / <code>math.log(x)</code></td><td>指数 / 自然対数</td></tr>
|
||||
<tr><td><code>math.fmod(x, y)</code></td><td>剰余</td></tr>
|
||||
<tr><td><code>math.modf(x)</code></td><td>整数部と小数部を返す</td></tr>
|
||||
<tr><td><code>math.ldexp(m, e)</code> / <code>math.frexp(x)</code></td><td>仮数・指数の操作</td></tr>
|
||||
<tr><td><code>math.sinh/cosh/tanh(x)</code></td><td>双曲線関数</td></tr>
|
||||
<tr><td><code>math.random([m [, n]])</code></td><td>乱数。後述の注意あり</td></tr>
|
||||
<tr><td><code>math.randomseed(x)</code></td><td>乱数シードの設定</td></tr>
|
||||
<tr><td><code>math.type(x)</code></td><td>数値の種別を返す</td></tr>
|
||||
<tr><td><code>math.tointeger(x)</code></td><td>整数化できれば整数、できなければ nil</td></tr>
|
||||
<tr><td><code>math.maxinteger</code> / <code>math.mininteger</code></td><td>整数の上限・下限</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
<code>math.random</code> は実行のたびに現在のフレーム番号でシードが設定されます。
|
||||
そのため同じフレームの再描画では同じ結果になりますが、1 回の実行の中で連続して呼ぶと値は進みます。
|
||||
オブジェクトやフレームに対して安定した乱数が必要なときは
|
||||
<a href="anim.html"><code>anim.rand</code></a>・<code>anim.noise</code>・<code>obj.rand</code> を使ってください。
|
||||
</div>
|
||||
|
||||
<h2>string</h2>
|
||||
|
||||
<pre><code>format, len, sub, upper, lower, rep, reverse, find, match,
|
||||
gmatch, gsub, byte, char, dump, pack, unpack, packsize</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>string.format(fmt, ...)</code></td><td>書式付き文字列。例: <code>string.format("%.2f", x)</code></td></tr>
|
||||
<tr><td><code>string.len(s)</code></td><td>長さ(<code>#s</code> と同じ)</td></tr>
|
||||
<tr><td><code>string.sub(s, i [, j])</code></td><td>部分文字列</td></tr>
|
||||
<tr><td><code>string.upper(s)</code> / <code>string.lower(s)</code></td><td>大文字 / 小文字</td></tr>
|
||||
<tr><td><code>string.rep(s, n)</code></td><td>n 回繰り返した文字列</td></tr>
|
||||
<tr><td><code>string.reverse(s)</code></td><td>反転</td></tr>
|
||||
<tr><td><code>string.find(s, pat)</code></td><td>パターン検索</td></tr>
|
||||
<tr><td><code>string.match(s, pat)</code></td><td>パターンに一致した部分を返す</td></tr>
|
||||
<tr><td><code>string.gmatch(s, pat)</code></td><td>一致を順に返す反復子</td></tr>
|
||||
<tr><td><code>string.gsub(s, pat, repl)</code></td><td>置換</td></tr>
|
||||
<tr><td><code>string.byte(s [, i])</code> / <code>string.char(...)</code></td><td>文字コード↔文字</td></tr>
|
||||
<tr><td><code>string.pack/unpack/packsize</code></td><td>バイナリのパック・アンパック</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>table</h2>
|
||||
|
||||
<pre><code>insert, remove, sort, concat, unpack, move</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>table.insert(t, [pos,] v)</code></td><td>要素を追加・挿入</td></tr>
|
||||
<tr><td><code>table.remove(t [, pos])</code></td><td>要素を削除して返す</td></tr>
|
||||
<tr><td><code>table.sort(t [, comp])</code></td><td>並べ替え</td></tr>
|
||||
<tr><td><code>table.concat(t [, sep])</code></td><td>文字列に連結</td></tr>
|
||||
<tr><td><code>table.unpack(t)</code></td><td>テーブルを複数の値に展開</td></tr>
|
||||
<tr><td><code>table.move(a1, f, e, t [, a2])</code></td><td>要素の移動・コピー</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>bit32</h2>
|
||||
|
||||
<p>32 ビット整数のビット演算ライブラリです。</p>
|
||||
|
||||
<pre><code>band, bor, bxor, bnot, lshift, rshift, arshift,
|
||||
extract, replace, btest, countlz, countrz</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>関数</th><th>説明</th></tr>
|
||||
<tr><td><code>bit32.band(...)</code></td><td>ビット積</td></tr>
|
||||
<tr><td><code>bit32.bor(...)</code></td><td>ビット和</td></tr>
|
||||
<tr><td><code>bit32.bxor(...)</code></td><td>排他的論理和</td></tr>
|
||||
<tr><td><code>bit32.bnot(x)</code></td><td>ビット反転</td></tr>
|
||||
<tr><td><code>bit32.lshift(x, n)</code> / <code>bit32.rshift(x, n)</code></td><td>左 / 右シフト</td></tr>
|
||||
<tr><td><code>bit32.arshift(x, n)</code></td><td>算術右シフト</td></tr>
|
||||
<tr><td><code>bit32.extract(n, f [, w])</code></td><td>ビット列の取り出し</td></tr>
|
||||
<tr><td><code>bit32.replace(n, v, f [, w])</code></td><td>ビット列の置き換え</td></tr>
|
||||
<tr><td><code>bit32.btest(...)</code></td><td>ビット積が 0 でないか</td></tr>
|
||||
<tr><td><code>bit32.countlz(x)</code> / <code>bit32.countrz(x)</code></td><td>先頭 / 末尾の 0 ビット数</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="pager">
|
||||
<a href="lua-basics.html">← Lua の基礎</a>
|
||||
<a href="globals.html">グローバル変数 →</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<script src="assets/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+231
-12
@@ -22,6 +22,7 @@ local mapSize = tonumber(arg[2])
|
||||
local workEventName = arg[3]
|
||||
local doneEventName = arg[4]
|
||||
local shimPath = arg[5]
|
||||
local stringParamsCap = tonumber(arg[6])
|
||||
|
||||
local hMap = k32.OpenFileMappingA(FILE_MAP_ALL_ACCESS, 0, mapName)
|
||||
assert(hMap ~= nil, "OpenFileMapping failed")
|
||||
@@ -49,12 +50,14 @@ local OFF_CB_FOUND = 10
|
||||
local OFF_CB_KIND = 11
|
||||
local OFF_LOAD_RESULT_W = 12
|
||||
local OFF_LOAD_RESULT_H = 13
|
||||
local OFF_STRING_PARAMS_LEN = 14
|
||||
local SCRIPT_OFFSET = 64 + 64 * 8
|
||||
local ERROR_OFFSET = SCRIPT_OFFSET + 128 * 1024
|
||||
local CB_TAG_OFFSET = ERROR_OFFSET + 4 * 1024
|
||||
local CB_TAG_MAX = 4096
|
||||
local CB_RESULT_OFFSET = CB_TAG_OFFSET + CB_TAG_MAX
|
||||
local PIXEL_OFFSET = CB_RESULT_OFFSET + 8 * 8
|
||||
local STRING_PARAMS_OFFSET = CB_RESULT_OFFSET + 8 * 8
|
||||
local PIXEL_OFFSET = STRING_PARAMS_OFFSET + stringParamsCap
|
||||
local FIRST_WRITABLE = 8
|
||||
local LAST_WRITABLE = 25
|
||||
local STATUS_CALLBACK = 3
|
||||
@@ -66,6 +69,7 @@ local CB_KIND_DRAWPOLY = 4
|
||||
local CB_KIND_LOADTEXT = 5
|
||||
local CB_KIND_LOADIMAGE = 6
|
||||
local CB_KIND_LOADMOVIE = 7
|
||||
local CB_KIND_SETANCHOR = 8
|
||||
|
||||
assert(loadfile(shimPath))()
|
||||
|
||||
@@ -84,6 +88,131 @@ local buffers = {}
|
||||
local options = {}
|
||||
local pixeloptions = {}
|
||||
local dirty = false
|
||||
local drawTarget = "frame"
|
||||
|
||||
local function sampleSource(src, srcW, srcH, u, v, linear)
|
||||
if not linear then
|
||||
local su = clamp(math.floor(u), 0, srcW - 1)
|
||||
local sv = clamp(math.floor(v), 0, srcH - 1)
|
||||
local si = (sv * srcW + su) * 4
|
||||
return src[si], src[si + 1], src[si + 2], src[si + 3]
|
||||
end
|
||||
local fx = u - 0.5
|
||||
local fy = v - 0.5
|
||||
local x0 = math.floor(fx)
|
||||
local y0 = math.floor(fy)
|
||||
local tx = fx - x0
|
||||
local ty = fy - y0
|
||||
local b, g, r, a = 0, 0, 0, 0
|
||||
for j = 0, 1 do
|
||||
local sy = clamp(y0 + j, 0, srcH - 1)
|
||||
local wy = (j == 0) and (1 - ty) or ty
|
||||
for i = 0, 1 do
|
||||
local sx = clamp(x0 + i, 0, srcW - 1)
|
||||
local w = wy * ((i == 0) and (1 - tx) or tx)
|
||||
local si = (sy * srcW + sx) * 4
|
||||
b = b + src[si] * w
|
||||
g = g + src[si + 1] * w
|
||||
r = r + src[si + 2] * w
|
||||
a = a + src[si + 3] * w
|
||||
end
|
||||
end
|
||||
return b, g, r, a
|
||||
end
|
||||
|
||||
local function compositeOver(dst, di, sb, sg, sr, sa)
|
||||
local inv = 1 - sa / 255
|
||||
dst[di] = math.floor(clamp(sb + dst[di] * inv, 0, 255))
|
||||
dst[di + 1] = math.floor(clamp(sg + dst[di + 1] * inv, 0, 255))
|
||||
dst[di + 2] = math.floor(clamp(sr + dst[di + 2] * inv, 0, 255))
|
||||
dst[di + 3] = math.floor(clamp(sa + dst[di + 3] * inv, 0, 255))
|
||||
end
|
||||
|
||||
local function compositeDrawInto(dst, dstW, dstH, src, srcW, srcH, ox, oy, zoom, aspect, alpha, linear)
|
||||
if srcW <= 0 or srcH <= 0 or dstW <= 0 or dstH <= 0 then return end
|
||||
local ca = clamp(aspect, -1, 1)
|
||||
local zx = zoom * (1 + ca)
|
||||
local zy = zoom * (1 - ca)
|
||||
if zx == 0 or zy == 0 then return end
|
||||
local ka = clamp(alpha, 0, 1)
|
||||
if ka <= 0 then return end
|
||||
local halfW = srcW * 0.5
|
||||
local halfH = srcH * 0.5
|
||||
local spanX = math.abs(halfW * zx)
|
||||
local spanY = math.abs(halfH * zy)
|
||||
local x0 = math.max(0, math.floor(ox - spanX))
|
||||
local x1 = math.min(dstW - 1, math.ceil(ox + spanX))
|
||||
local y0 = math.max(0, math.floor(oy - spanY))
|
||||
local y1 = math.min(dstH - 1, math.ceil(oy + spanY))
|
||||
for py = y0, y1 do
|
||||
for px = x0, x1 do
|
||||
local u = (px + 0.5 - ox) / zx + halfW
|
||||
local v = (py + 0.5 - oy) / zy + halfH
|
||||
if u >= 0 and u < srcW and v >= 0 and v < srcH then
|
||||
local sb, sg, sr, sa = sampleSource(src, srcW, srcH, u, v, linear)
|
||||
compositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function compositeDrawPolyInto(dst, dstW, dstH, src, srcW, srcH, poly, alpha, linear)
|
||||
if srcW <= 0 or srcH <= 0 or dstW <= 0 or dstH <= 0 then return end
|
||||
local x0p, y0p = poly[0], poly[1]
|
||||
local x1p, y1p = poly[3], poly[4]
|
||||
local x3p, y3p = poly[9], poly[10]
|
||||
local u0, v0 = poly[12], poly[13]
|
||||
local u1, v1 = poly[14], poly[15]
|
||||
local u3, v3 = poly[18], poly[19]
|
||||
local det = u0 * (v1 - v3) - v0 * (u1 - u3) + (u1 * v3 - v1 * u3)
|
||||
if math.abs(det) < 1e-9 then return end
|
||||
local inv = 1 / det
|
||||
local a = (x0p * (v1 - v3) - v0 * (x1p - x3p) + (x1p * v3 - v1 * x3p)) * inv
|
||||
local b = (u0 * (x1p - x3p) - x0p * (u1 - u3) + (u1 * x3p - x1p * u3)) * inv
|
||||
local c = (u0 * (v1 * x3p - x1p * v3) - v0 * (u1 * x3p - x1p * u3) + x0p * (u1 * v3 - v1 * u3)) * inv
|
||||
local d = (y0p * (v1 - v3) - v0 * (y1p - y3p) + (y1p * v3 - v1 * y3p)) * inv
|
||||
local e = (u0 * (y1p - y3p) - y0p * (u1 - u3) + (u1 * y3p - y1p * u3)) * inv
|
||||
local f = (u0 * (v1 * y3p - y1p * v3) - v0 * (u1 * y3p - y1p * u3) + y0p * (u1 * v3 - v1 * u3)) * inv
|
||||
local adet = a * e - b * d
|
||||
if math.abs(adet) < 1e-9 then return end
|
||||
local ka = clamp(alpha, 0, 1)
|
||||
if ka <= 0 then return end
|
||||
local minX, minY, maxX, maxY = poly[0], poly[1], poly[0], poly[1]
|
||||
for i = 0, 3 do
|
||||
local xx = poly[i * 3]
|
||||
local yy = poly[i * 3 + 1]
|
||||
if xx < minX then minX = xx end
|
||||
if xx > maxX then maxX = xx end
|
||||
if yy < minY then minY = yy end
|
||||
if yy > maxY then maxY = yy end
|
||||
end
|
||||
local bx0 = math.max(0, math.floor(minX))
|
||||
local bx1 = math.min(dstW - 1, math.ceil(maxX))
|
||||
local by0 = math.max(0, math.floor(minY))
|
||||
local by1 = math.min(dstH - 1, math.ceil(maxY))
|
||||
for py = by0, by1 do
|
||||
for px = bx0, bx1 do
|
||||
local dx = (px + 0.5) - c
|
||||
local dy = (py + 0.5) - f
|
||||
local u = (e * dx - b * dy) / adet
|
||||
local v = (-d * dx + a * dy) / adet
|
||||
if u >= 0 and u < srcW and v >= 0 and v < srcH then
|
||||
local sb, sg, sr, sa = sampleSource(src, srcW, srcH, u, v, linear)
|
||||
compositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ensureTemp()
|
||||
local t = buffers["t"]
|
||||
if not t then
|
||||
local n = width * height * 4
|
||||
t = { data = ffi.new("uint8_t[?]", n), w = width, h = height }
|
||||
buffers["t"] = t
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function bufferKind(id)
|
||||
local c = id:match("^%s*(.)")
|
||||
@@ -96,6 +225,7 @@ local function bufferKind(id)
|
||||
return c, c
|
||||
end
|
||||
|
||||
local sandbox
|
||||
local obj = {}
|
||||
local scene = {}
|
||||
local ymm4 = {}
|
||||
@@ -316,6 +446,12 @@ function obj.effect(name, ...)
|
||||
end
|
||||
|
||||
function obj.draw(ox, oy, oz, zoom, alpha, aspect)
|
||||
if drawTarget == "temp" then
|
||||
local t = ensureTemp()
|
||||
compositeDrawInto(t.data, t.w, t.h, pixels, width, height,
|
||||
ox or 0, oy or 0, zoom or 1, aspect or 0, alpha or 1, (options.antialias or 1) ~= 0)
|
||||
return
|
||||
end
|
||||
cbResult[0] = ox or 0
|
||||
cbResult[1] = oy or 0
|
||||
cbResult[2] = oz or 0
|
||||
@@ -323,6 +459,7 @@ function obj.draw(ox, oy, oz, zoom, alpha, aspect)
|
||||
cbResult[4] = alpha or 1
|
||||
cbResult[5] = aspect or 0
|
||||
cbResult[6] = options.antialias or 1
|
||||
cbResult[7] = options.blend or 0
|
||||
i32[OFF_CB_KIND] = CB_KIND_DRAW
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
@@ -333,14 +470,15 @@ function obj.drawpoly(...)
|
||||
local n = select("#", ...)
|
||||
if n < 12 then return end
|
||||
local a = { ... }
|
||||
for i = 0, 11 do cbTagD[i] = a[i + 1] or 0 end
|
||||
local p = {}
|
||||
for i = 0, 11 do p[i] = a[i + 1] or 0 end
|
||||
if n >= 20 then
|
||||
for i = 0, 7 do cbTagD[12 + i] = a[13 + i] or 0 end
|
||||
for i = 0, 7 do p[12 + i] = a[13 + i] or 0 end
|
||||
else
|
||||
cbTagD[12] = 0; cbTagD[13] = 0
|
||||
cbTagD[14] = width; cbTagD[15] = 0
|
||||
cbTagD[16] = width; cbTagD[17] = height
|
||||
cbTagD[18] = 0; cbTagD[19] = height
|
||||
p[12] = 0; p[13] = 0
|
||||
p[14] = width; p[15] = 0
|
||||
p[16] = width; p[17] = height
|
||||
p[18] = 0; p[19] = height
|
||||
end
|
||||
local alpha = 1
|
||||
if n == 13 then
|
||||
@@ -348,8 +486,15 @@ function obj.drawpoly(...)
|
||||
elseif n >= 21 then
|
||||
alpha = a[21] or 1
|
||||
end
|
||||
cbTagD[20] = alpha
|
||||
p[20] = alpha
|
||||
if drawTarget == "temp" then
|
||||
local t = ensureTemp()
|
||||
compositeDrawPolyInto(t.data, t.w, t.h, pixels, width, height, p, alpha, (options.antialias or 1) ~= 0)
|
||||
return
|
||||
end
|
||||
for i = 0, 20 do cbTagD[i] = p[i] end
|
||||
cbTagD[21] = options.antialias or 1
|
||||
cbTagD[22] = options.blend or 0
|
||||
i32[OFF_CB_KIND] = CB_KIND_DRAWPOLY
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
@@ -363,10 +508,22 @@ function obj.getvalue(target)
|
||||
return 0
|
||||
end
|
||||
|
||||
function obj.setoption(name, value)
|
||||
function obj.setoption(name, value, a, b)
|
||||
if type(name) ~= "string" then return end
|
||||
if value == nil then value = true end
|
||||
options[name] = value
|
||||
if name == "drawtarget" then
|
||||
if value == "tempbuffer" then
|
||||
drawTarget = "temp"
|
||||
if a ~= nil and b ~= nil then
|
||||
local w = math.max(1, math.floor(a))
|
||||
local h = math.max(1, math.floor(b))
|
||||
buffers["t"] = { data = ffi.new("uint8_t[?]", w * h * 4), w = w, h = h }
|
||||
end
|
||||
else
|
||||
drawTarget = "frame"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function obj.getoption(name)
|
||||
@@ -382,12 +539,52 @@ function obj.pixeloption(name, value)
|
||||
pixeloptions[name] = value
|
||||
end
|
||||
|
||||
function obj.setanchor(name, count, ...)
|
||||
if type(name) ~= "string" then return 0 end
|
||||
count = math.floor(count or 0)
|
||||
if count < 0 then count = 0 elseif count > 32 then count = 32 end
|
||||
if name == "track" then return 0 end
|
||||
|
||||
local connection, is3d = 0, false
|
||||
local optCount = select("#", ...)
|
||||
for i = 1, optCount do
|
||||
local o = select(i, ...)
|
||||
if o == "line" then connection = 1
|
||||
elseif o == "loop" then connection = 2
|
||||
elseif o == "star" then connection = 3
|
||||
elseif o == "arm" then connection = 4
|
||||
elseif o == "xyz" then is3d = true end
|
||||
end
|
||||
|
||||
local len = #name
|
||||
if len > CB_TAG_MAX then len = CB_TAG_MAX end
|
||||
ffi.copy(base + CB_TAG_OFFSET, name, len)
|
||||
i32[OFF_CB_TAGLEN] = len
|
||||
cbResult[0] = count
|
||||
cbResult[1] = is3d and 1 or 0
|
||||
cbResult[2] = connection
|
||||
i32[OFF_CB_KIND] = CB_KIND_SETANCHOR
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
k32.WaitForSingleObject(workEvent, INFINITE)
|
||||
|
||||
local stride = is3d and 3 or 2
|
||||
local pos = {}
|
||||
for i = 0, count - 1 do
|
||||
pos[i * stride + 1] = cbTagD[i * stride + 0]
|
||||
pos[i * stride + 2] = cbTagD[i * stride + 1]
|
||||
if is3d then pos[i * stride + 3] = cbTagD[i * stride + 2] end
|
||||
end
|
||||
sandbox[name] = pos
|
||||
return count
|
||||
end
|
||||
|
||||
function obj.copybuffer(dst, src)
|
||||
if type(dst) ~= "string" or type(src) ~= "string" then return end
|
||||
local sk, skey = bufferKind(src)
|
||||
local data, w, h
|
||||
if sk == "o" then
|
||||
data = ffi.string(pixels, width * height * 4)
|
||||
data = pixels
|
||||
w = width; h = height
|
||||
elseif sk == "t" or sk == "c" then
|
||||
local b = buffers[skey]
|
||||
@@ -410,7 +607,10 @@ function obj.copybuffer(dst, src)
|
||||
obj.cz = 0
|
||||
obj.diagonal = math.sqrt(w * w + h * h)
|
||||
elseif dk == "t" or dk == "c" then
|
||||
buffers[dkey] = { data = data, w = w, h = h }
|
||||
local n = w * h * 4
|
||||
local arr = ffi.new("uint8_t[?]", n)
|
||||
ffi.copy(arr, data, n)
|
||||
buffers[dkey] = { data = arr, w = w, h = h }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -457,7 +657,7 @@ function obj.getobject(tag, frame)
|
||||
return buildObject()
|
||||
end
|
||||
|
||||
local sandbox = {
|
||||
sandbox = {
|
||||
obj = obj, scene = scene, ymm4 = ymm4,
|
||||
anim = anim, bit32 = bit32, rawlen = rawlen,
|
||||
math = math, string = string, table = table,
|
||||
@@ -483,6 +683,7 @@ local function loadFields()
|
||||
obj.rx = f64[20]; obj.ry = f64[21]; obj.rz = f64[22]
|
||||
obj.rxr = f64[23]; obj.ryr = f64[24]; obj.rzr = f64[25]
|
||||
obj.track0 = f64[26]; obj.track1 = f64[27]; obj.track2 = f64[28]; obj.track3 = f64[29]
|
||||
obj.slider0 = f64[58]; obj.slider1 = f64[59]; obj.slider2 = f64[60]; obj.slider3 = f64[61]
|
||||
obj.time = f64[30]; obj.frame = f64[31]; obj.totalframe = f64[32]; obj.totaltime = f64[33]
|
||||
obj.t = f64[34]; obj.framerate = f64[35]; obj.layer = f64[36]; obj.index = f64[37]; obj.num = f64[38]
|
||||
scene.width = f64[39]; scene.height = f64[40]; scene.cx = f64[41]; scene.cy = f64[42]
|
||||
@@ -496,6 +697,20 @@ local function loadFields()
|
||||
sandbox.color = (f64[57] >= 0) and f64[57] or nil
|
||||
end
|
||||
|
||||
local function loadStringParams()
|
||||
if i32[OFF_STRING_PARAMS_LEN] <= 0 then return end
|
||||
local p = base + STRING_PARAMS_OFFSET
|
||||
local count = ffi.cast("int32_t*", p)[0]
|
||||
local pos = 4
|
||||
for _ = 1, count do
|
||||
local nameLen = ffi.cast("int32_t*", p + pos)[0]; pos = pos + 4
|
||||
local name = ffi.string(p + pos, nameLen); pos = pos + nameLen
|
||||
local valLen = ffi.cast("int32_t*", p + pos)[0]; pos = pos + 4
|
||||
local val = ffi.string(p + pos, valLen); pos = pos + valLen
|
||||
obj[name] = val
|
||||
end
|
||||
end
|
||||
|
||||
local function storeFields()
|
||||
for i = FIRST_WRITABLE, LAST_WRITABLE do
|
||||
local key
|
||||
@@ -534,15 +749,19 @@ while true do
|
||||
|
||||
if compiledChunk and code == compiledCode then
|
||||
loadFields()
|
||||
loadStringParams()
|
||||
cacheTag = nil
|
||||
for k in pairs(options) do options[k] = nil end
|
||||
for k in pairs(pixeloptions) do pixeloptions[k] = nil end
|
||||
drawTarget = "frame"
|
||||
font.family = ""; font.size = 34; font.bold = false; font.italic = false; font.color = 0xFFFFFF
|
||||
math.randomseed(f64[31])
|
||||
setfenv(compiledChunk, sandbox)
|
||||
local ok, err = pcall(compiledChunk)
|
||||
if ok then
|
||||
storeFields()
|
||||
local ds = options.draw_state
|
||||
if ds == nil then f64[62] = 0 elseif ds == false or ds == 0 then f64[62] = 2 else f64[62] = 1 end
|
||||
i32[OFF_PIXELSDIRTY] = dirty and 1 or 0
|
||||
i32[OFF_STATUS] = 1
|
||||
k32.SetEvent(doneEvent)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする