コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
d7f981c38a
|
||
|
|
df0c63a270
|
||
|
|
7766b116dc
|
||
|
|
eb8f4e8055
|
||
|
|
04563a7242
|
||
|
|
875d954520
|
||
|
|
bd7f2ae691
|
||
|
|
36b3c880fe
|
||
|
|
230e6f010c
|
||
|
|
ef16ae64fb
|
||
|
|
0204d480e2
|
||
|
|
7e1f2c1d7c
|
||
|
|
bab81d27e5
|
||
|
|
a3efd55ce6
|
||
|
|
4f2389702a
|
||
|
|
247bb83230
|
||
|
|
1d495039f0
|
||
|
|
56d7937be1
|
検索条件に一致するファイルはありません
+39
-23
@@ -1,40 +1,56 @@
|
||||
# v1.3.4 - Lua スクリプト for YMM4
|
||||
# v1.6.0 - Lua スクリプト for YMM4
|
||||
|
||||
ネイティブ実行中の **`obj.getobject` を高速化**したリリースです。
|
||||
同じオブジェクトを繰り返し参照するスクリプトで、本体プロセスへの問い合わせ回数を
|
||||
削減し、大幅に高速化しました。
|
||||
AviUtl のアニメーション効果スクリプト互換層に**動的パラメータの UI 反映**を
|
||||
追加したリリースです。スクリプトのヘッダに記述した `--track` / `--check` /
|
||||
`--color` の宣言が、エディタのパラメータUIへ自動的に反映されるようになりました。
|
||||
|
||||
---
|
||||
|
||||
## 改善
|
||||
## 新機能
|
||||
|
||||
### 1. 同一オブジェクト参照のキャッシュによる高速化
|
||||
### 1. AviUtl ヘッダ宣言に応じた動的パラメータUI
|
||||
|
||||
ネイティブ実行中の `obj.getobject` は、解決に必要なシーン情報が本体プロセス側にしか
|
||||
存在しないため、呼び出しごとに本体プロセスへの問い合わせ(往復)を伴います。この往復は
|
||||
1 回あたりのコストが大きく、同じオブジェクトをループ内で繰り返し参照すると無視できない
|
||||
負荷になっていました。
|
||||
スクリプト先頭の `--track0`〜`--track3` / `--check0`〜`--check3` / `--color` を
|
||||
解析し、宣言された項目だけをエディタUIへ表示します。AviUtl の仕様に準じ、
|
||||
トラックバーは最大4個、チェックボックスは最大4個、カラーは1個です。
|
||||
|
||||
本リリースでは、**同じタグ・同じフレームへの連続した問い合わせをフレーム内でキャッシュ**
|
||||
するようにしました。2 回目以降は本体への往復を行わずにキャッシュした結果を返すため、
|
||||
同一オブジェクトを繰り返し参照するスクリプトでは問い合わせ回数が 1 回に削減されます。
|
||||
内部計測では、該当パターンが 1000 倍以上高速化することを確認しています。返り値は従来
|
||||
どおり呼び出しごとに新しいテーブルであり、出力結果は変わりません。
|
||||
- `--track番号:名前,最小,最大,初期値,移動量`: 宣言されたトラックのスライダーを
|
||||
表示します。トラック値は評価時にヘッダの最小〜最大へクランプされ、`obj.track0`〜
|
||||
`obj.track3` から参照できます。
|
||||
- `--check番号:名前,初期値`: トグルスライダーを表示します。値は `obj.check0`〜
|
||||
`obj.check3` から真偽値(false / true)として参照できます。
|
||||
- `--color:色`: カラーピッカーを表示します。選択した色はグローバル変数 `color`
|
||||
(0xRRGGBB)として参照できます。
|
||||
- 宣言が一つも無い場合は、従来どおり Track0〜Track3 の4スライダー表示へ戻ります。
|
||||
- 各項目のラベルは多言語化された固定スロット(Track0〜3 / Check0〜3 / Color)で
|
||||
表示されます。設定した値はプロジェクトファイルに保存され、再現できます。
|
||||
|
||||
---
|
||||
|
||||
## 注意事項
|
||||
|
||||
- キャッシュが効くのは、同じタグ・同じフレームへの連続した問い合わせです。毎回異なる
|
||||
オブジェクトやフレームを参照する場合は、その都度本体プロセスへの往復が発生します。
|
||||
この場合は結果を変数へ保持して呼び出し回数を抑えることを推奨します。
|
||||
- ラベルは固定スロット番号で表示され、スクリプト内に記述したパラメータ名
|
||||
(例: `--track0:X速度,...` の「X速度」)は UI ラベルへは反映されません。
|
||||
- トラックのスライダー操作範囲は従来どおり -100〜100 で、ヘッダの範囲・既定値は
|
||||
スライダーの表示そのものには反映されません。トラック値は評価時にヘッダの
|
||||
最小〜最大へクランプされます。新規に宣言されたチェック・色にはヘッダの既定値が
|
||||
適用されますが、トラックには適用されず初期値は 0 のままです。
|
||||
- `--dialog`(`/chk`・`/col`・`/fig`)、`--file`、`--font` には対応していません。
|
||||
- 本変更に伴い、`--check` / `--color` の擬似展開(従来 `obj.checkN` や `color` を
|
||||
スクリプト先頭へ自動挿入していた挙動)は廃止され、値は UI から供給されます。
|
||||
`--dialog` / `--param` の展開は従来どおりです。
|
||||
|
||||
---
|
||||
|
||||
## 内部実装
|
||||
|
||||
- ワーカー側に直前の問い合わせ結果のキャッシュを設け、同一タグ・同一フレームへの連続
|
||||
呼び出しでは本体への往復を省きます。キャッシュは各フレームの実行開始時に破棄されるため、
|
||||
フレームをまたいで古い結果が再利用されることはありません。
|
||||
- 本体側ではタグ文字列の確保を使い回し、問い合わせごとのアロケーションを抑えることで、
|
||||
長時間の出力における GC 負荷を軽減しました。
|
||||
- AviUtl ヘッダ(`--track` / `--check` / `--color`)を解析するレイアウト解析を
|
||||
追加しました。走査範囲は既存の互換変換と同じく最初の `@` セクションより前です。
|
||||
- 解析結果に基づき、`[ShowPropertyEditorWhen]` による項目ごとの動的表示と、
|
||||
評価時のトラック値クランプを実装しました。
|
||||
- `obj.check0`〜`obj.check3`(真偽値)とグローバル `color` を、MoonSharp および
|
||||
ネイティブ(LuaJIT)双方の実行経路へ配線しました。
|
||||
- 互換変換から `--check` / `--color` の擬似展開を廃止し、UI を値の唯一のソースに
|
||||
しました。
|
||||
- チェック・色のラベルを多言語リソースへ追加しました。
|
||||
- ヘッダ解析および互換変換の挙動変更に関するユニットテストを追加・更新しました。
|
||||
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
Luaスクリプト for YMM4 v1.3.4
|
||||
Luaスクリプト for YMM4 v1.6.0
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、Luaスクリプトで映像エフェクトのパラメータや
|
||||
ピクセルを直接制御できるプラグインです。
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using LuaScript.Compat;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AviUtlParameterLayoutTests
|
||||
{
|
||||
[Fact]
|
||||
public void NoDirectives_HasAnyIsFalse()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("obj.x = 1\nobj.y = 2");
|
||||
Assert.False(layout.HasAny);
|
||||
Assert.False(layout.HasTrack(0));
|
||||
Assert.False(layout.HasColor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Track_ParsesNameRangeDefaultStep()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--track0:Amp,0,100,10,0.5\nobj.ox = obj.track0");
|
||||
Assert.True(layout.HasAny);
|
||||
var t = layout.GetTrack(0);
|
||||
Assert.NotNull(t);
|
||||
Assert.Equal("Amp", t!.Value.Name);
|
||||
Assert.Equal(0d, t.Value.Min);
|
||||
Assert.Equal(100d, t.Value.Max);
|
||||
Assert.Equal(10d, t.Value.Default);
|
||||
Assert.Equal(0.5d, t.Value.Step);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Track_DefaultIsClampedIntoRange()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--track1:V,0,10,999");
|
||||
var t = layout.GetTrack(1);
|
||||
Assert.Equal(10d, t!.Value.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Track_SwapsInvertedMinMax()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--track0:V,100,0,50");
|
||||
var t = layout.GetTrack(0);
|
||||
Assert.Equal(0d, t!.Value.Min);
|
||||
Assert.Equal(100d, t.Value.Max);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Track_NegativeRangeParses()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--track2:Off,-100,100,-25");
|
||||
var t = layout.GetTrack(2);
|
||||
Assert.Equal(-100d, t!.Value.Min);
|
||||
Assert.Equal(-25d, t.Value.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Track_IndexBeyondThreeIsIgnored()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--track4:V,0,10,5");
|
||||
Assert.False(layout.HasAny);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Check_ParsesDefaultAsBool()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--check0:On,1\n--check1:Off,0");
|
||||
Assert.True(layout.GetCheck(0)!.Value.Default);
|
||||
Assert.False(layout.GetCheck(1)!.Value.Default);
|
||||
Assert.Equal("On", layout.GetCheck(0)!.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Color_ParsesHexLiteral()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--color:0xff8800");
|
||||
Assert.True(layout.HasColor);
|
||||
Assert.Equal(0xff8800, layout.Color!.Value.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Color_ParsesDecimalLiteral()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--color:255");
|
||||
Assert.Equal(255, layout.Color!.Value.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Combined_TrackCheckColorAllDetected()
|
||||
{
|
||||
const string src =
|
||||
"--track0:Amp,0,100,10\n" +
|
||||
"--track1:Spd,0,50,5\n" +
|
||||
"--check0:Enable,1\n" +
|
||||
"--color:0x112233\n" +
|
||||
"obj.ox = obj.track0";
|
||||
var layout = AviUtlParameterLayout.Parse(src);
|
||||
Assert.True(layout.HasTrack(0));
|
||||
Assert.True(layout.HasTrack(1));
|
||||
Assert.False(layout.HasTrack(2));
|
||||
Assert.True(layout.HasCheck(0));
|
||||
Assert.True(layout.HasColor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Section_OnlyFirstSectionHeaderIsScanned()
|
||||
{
|
||||
const string src = "@First\n--track0:A,0,10,3\n@Second\n--track1:B,0,10,4";
|
||||
var layout = AviUtlParameterLayout.Parse(src);
|
||||
Assert.True(layout.HasTrack(0));
|
||||
Assert.False(layout.HasTrack(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EngineDirective_IsNotMistakenForParameter()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse("--!native\nobj.x = 1");
|
||||
Assert.False(layout.HasAny);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using LuaScript.Compat;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AviUtlRandomEquivalenceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Rand_StaysWithinRequestedRange()
|
||||
{
|
||||
for (int seed = 0; seed < 64; seed++)
|
||||
{
|
||||
double value = AviUtlRandom.Next(-3, 7, seed, seed * 3 + 1);
|
||||
Assert.InRange(value, -3d, 7d);
|
||||
Assert.Equal(Math.Floor(value), value);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rand_IsDeterministicForSameInputs()
|
||||
{
|
||||
Assert.Equal(
|
||||
AviUtlRandom.Next(0, 100, 5, 12),
|
||||
AviUtlRandom.Next(0, 100, 5, 12));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rand_MatchesBetweenMoonSharpAndLuaJit()
|
||||
{
|
||||
var lane = new LuaJitLane();
|
||||
Assert.True(lane.Available, "native/luajit.exe must be present");
|
||||
|
||||
var cases = new List<(double A, double B, double Seed, double Frame)>();
|
||||
for (int seed = 0; seed < 16; seed++)
|
||||
for (int frame = 0; frame < 4; frame++)
|
||||
{
|
||||
cases.Add((0d, 100d, seed, frame));
|
||||
cases.Add((-50d, 50d, seed + 1, frame * 7));
|
||||
cases.Add((1d, 6d, seed * 13, frame));
|
||||
cases.Add((-3.5d, 3.5d, seed, frame + 1000));
|
||||
}
|
||||
|
||||
var exprs = new List<string>(cases.Count);
|
||||
foreach (var c in cases)
|
||||
exprs.Add($"aviutl_rand({L(c.A)},{L(c.B)},{L(c.Seed)},{L(c.Frame)})");
|
||||
|
||||
string[] lines = lane.Eval(exprs);
|
||||
Assert.Equal(exprs.Count, lines.Length);
|
||||
|
||||
var failures = new List<string>();
|
||||
for (int i = 0; i < cases.Count; i++)
|
||||
{
|
||||
double expected = AviUtlRandom.Next(cases[i].A, cases[i].B, cases[i].Seed, cases[i].Frame);
|
||||
if (!double.TryParse(lines[i], NumberStyles.Float, CultureInfo.InvariantCulture, out var got))
|
||||
{
|
||||
failures.Add($"{exprs[i]} => luajit '{lines[i]}' (not a number), expected {expected}");
|
||||
continue;
|
||||
}
|
||||
if (got != expected)
|
||||
failures.Add($"{exprs[i]} => luajit {got}, moonsharp {expected}");
|
||||
}
|
||||
|
||||
Assert.True(failures.Count == 0,
|
||||
$"{failures.Count}/{cases.Count} mismatches:\n" + string.Join("\n", failures.GetRange(0, Math.Min(25, failures.Count))));
|
||||
}
|
||||
|
||||
private static string L(double value) => value.ToString("R", CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using LuaScript.Compat;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AviUtlScriptTests
|
||||
{
|
||||
private static Script NewScript()
|
||||
{
|
||||
var script = new Script(
|
||||
CoreModules.Basic |
|
||||
CoreModules.Math |
|
||||
CoreModules.String |
|
||||
CoreModules.Table |
|
||||
CoreModules.Bit32 |
|
||||
CoreModules.TableIterators |
|
||||
CoreModules.Metatables |
|
||||
CoreModules.ErrorHandling);
|
||||
script.Globals["obj"] = new Table(script);
|
||||
return script;
|
||||
}
|
||||
|
||||
private static double RunNumber(string transformed, string global = "result")
|
||||
{
|
||||
var script = NewScript();
|
||||
script.DoString(transformed);
|
||||
return script.Globals.Get(global).Number;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlainScript_IsReturnedUnchanged()
|
||||
{
|
||||
const string source = "obj.x = 1\nobj.y = 2";
|
||||
Assert.Equal(source, AviUtlScript.Transform(source));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TrackOnlyHeader_IsReturnedUnchanged()
|
||||
{
|
||||
const string source = "--track0:Amp,0,100,10\nobj.ox = obj.track0";
|
||||
Assert.Equal(source, AviUtlScript.Transform(source));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DirectiveComment_IsNotConfusedWithDirective()
|
||||
{
|
||||
const string source = "-- color reference note\nobj.x = 1";
|
||||
Assert.Equal(source, AviUtlScript.Transform(source));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EngineDirective_IsPreserved()
|
||||
{
|
||||
const string source = "--!native\n--dialog:V,local v=3;\nresult = v";
|
||||
string transformed = AviUtlScript.Transform(source);
|
||||
Assert.Contains("--!native", transformed);
|
||||
Assert.Equal(3d, RunNumber(transformed));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Dialog_InjectsDefaultDeclarations()
|
||||
{
|
||||
const string source = "--dialog:Angle,local angle=45;Dist,local dist=100;\nresult = dist";
|
||||
double result = RunNumber(AviUtlScript.Transform(source));
|
||||
Assert.Equal(100d, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Color_IsNotInjected_SurfacedAsUiParameter()
|
||||
{
|
||||
const string source = "--color:0x010203\nresult = color";
|
||||
Assert.Equal(source, AviUtlScript.Transform(source));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Check_IsNotInjected_SurfacedAsUiParameter()
|
||||
{
|
||||
const string source = "--check0:Enable,1\nresult = obj.check0";
|
||||
Assert.Equal(source, AviUtlScript.Transform(source));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Param_InjectsRawLua()
|
||||
{
|
||||
const string source = "--param:result = 7\nlocal x = 1";
|
||||
double result = RunNumber(AviUtlScript.Transform(source));
|
||||
Assert.Equal(7d, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Section_FirstSectionIsSelected()
|
||||
{
|
||||
const string source = "@First\n--dialog:A,local a=5;\nresult = a\n@Second\nresult = 999";
|
||||
double result = RunNumber(AviUtlScript.Transform(source));
|
||||
Assert.Equal(5d, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Section_PreambleBeforeFirstHeaderIsDiscarded()
|
||||
{
|
||||
const string source = "result = 111\n@Only\nresult = 222";
|
||||
double result = RunNumber(AviUtlScript.Transform(source));
|
||||
Assert.Equal(222d, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClassicTransformScript_RunsAndMovesObject()
|
||||
{
|
||||
const string source =
|
||||
"--track0:Range,0,2000,10\n" +
|
||||
"--dialog:Seed,local seed=3;\n" +
|
||||
"obj.ox = obj.ox + obj.track0 * obj.rand(-100,100,seed,obj.time) / 100";
|
||||
|
||||
var script = NewScript();
|
||||
var obj = script.Globals.Get("obj").Table;
|
||||
obj["ox"] = 0d;
|
||||
obj["track0"] = 500d;
|
||||
obj["time"] = 2d;
|
||||
obj["frame"] = 4d;
|
||||
obj["rand"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
double frameDefault = obj.Get("frame").CastToNumber() ?? 0d;
|
||||
double a = args.Count > 0 ? args[0].CastToNumber() ?? 0d : 0d;
|
||||
double b = args.Count > 1 ? args[1].CastToNumber() ?? 0d : 0d;
|
||||
double seed = args.Count > 2 ? args[2].CastToNumber() ?? 0d : 0d;
|
||||
double frame = args.Count > 3 ? args[3].CastToNumber() ?? frameDefault : frameDefault;
|
||||
return DynValue.NewNumber(AviUtlRandom.Next(a, b, seed, frame));
|
||||
});
|
||||
|
||||
script.DoString(AviUtlScript.Transform(source));
|
||||
double moved = obj.Get("ox").Number;
|
||||
|
||||
double expectedRand = AviUtlRandom.Next(-100, 100, 3, 2);
|
||||
Assert.Equal(500d * expectedRand / 100d, moved);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using LuaScript.Compat;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class FigureRendererTests
|
||||
{
|
||||
private static (int B, int G, int R, int A) Pixel(byte[] buffer, int width, int x, int y)
|
||||
{
|
||||
int i = (y * width + x) * 4;
|
||||
return (buffer[i], buffer[i + 1], buffer[i + 2], buffer[i + 3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Render_ProducesBufferOfRequestedSize()
|
||||
{
|
||||
var buffer = FigureRenderer.Render("円", 64, 48, 0xFFFFFF, 0d);
|
||||
Assert.Equal(64 * 48 * 4, buffer.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilledCircle_CenterIsOpaqueAndColored()
|
||||
{
|
||||
int w = 100, h = 100;
|
||||
var buffer = FigureRenderer.Render("円", w, h, 0xFF0000, 0d);
|
||||
var (b, g, r, a) = Pixel(buffer, w, w / 2, h / 2);
|
||||
Assert.Equal(255, a);
|
||||
Assert.Equal(255, r);
|
||||
Assert.Equal(0, g);
|
||||
Assert.Equal(0, b);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilledCircle_CornerIsTransparent()
|
||||
{
|
||||
int w = 100, h = 100;
|
||||
var buffer = FigureRenderer.Render("円", w, h, 0xFF0000, 0d);
|
||||
var (_, _, _, a) = Pixel(buffer, w, 0, 0);
|
||||
Assert.Equal(0, a);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Color_IsStoredPremultipliedAtHalfCoverageBoundary()
|
||||
{
|
||||
int w = 100, h = 100;
|
||||
var buffer = FigureRenderer.Render("四角形", w, h, 0x102030, 0d);
|
||||
var (b, g, r, a) = Pixel(buffer, w, w / 2, h / 2);
|
||||
Assert.Equal(255, a);
|
||||
Assert.Equal(0x10, r);
|
||||
Assert.Equal(0x20, g);
|
||||
Assert.Equal(0x30, b);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilledRectangle_CornerIsOpaque()
|
||||
{
|
||||
int w = 80, h = 80;
|
||||
var buffer = FigureRenderer.Render("四角形", w, h, 0xFFFFFF, 0d);
|
||||
var (_, _, _, a) = Pixel(buffer, w, 1, 1);
|
||||
Assert.Equal(255, a);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OutlinedCircle_IsHollowAtCenterButSolidNearEdge()
|
||||
{
|
||||
int w = 100, h = 100;
|
||||
var buffer = FigureRenderer.Render("円", w, h, 0xFFFFFF, 8d);
|
||||
var (_, _, _, center) = Pixel(buffer, w, w / 2, h / 2);
|
||||
var (_, _, _, nearEdge) = Pixel(buffer, w, w / 2 + 46, h / 2);
|
||||
Assert.Equal(0, center);
|
||||
Assert.Equal(255, nearEdge);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Triangle_CornersEmptyCentroidFilled()
|
||||
{
|
||||
int w = 100, h = 100;
|
||||
var buffer = FigureRenderer.Render("三角形", w, h, 0xFFFFFF, 0d);
|
||||
var (_, _, _, topLeft) = Pixel(buffer, w, 2, 2);
|
||||
var (_, _, _, topRight) = Pixel(buffer, w, w - 3, 2);
|
||||
var (_, _, _, centroid) = Pixel(buffer, w, w / 2, h / 2);
|
||||
Assert.Equal(0, topLeft);
|
||||
Assert.Equal(0, topRight);
|
||||
Assert.Equal(255, centroid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnknownName_FallsBackToRectangle()
|
||||
{
|
||||
int w = 40, h = 40;
|
||||
var buffer = FigureRenderer.Render("unknown", w, h, 0xFFFFFF, 0d);
|
||||
var (_, _, _, corner) = Pixel(buffer, w, 1, 1);
|
||||
Assert.Equal(255, corner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,10 @@
|
||||
<Compile Include="..\LuaScript\Engine\LuaJitWorker.cs" Link="Linked\LuaJitWorker.cs" />
|
||||
<Compile Include="..\LuaScript\SceneObjectInfo.cs" Link="Linked\SceneObjectInfo.cs" />
|
||||
<Compile Include="..\LuaScript\AnimTableRegistrar.cs" Link="Linked\AnimTableRegistrar.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlScript.cs" Link="Linked\AviUtlScript.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlParameterLayout.cs" Link="Linked\AviUtlParameterLayout.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\AviUtlRandom.cs" Link="Linked\AviUtlRandom.cs" />
|
||||
<Compile Include="..\LuaScript\Compat\FigureRenderer.cs" Link="Linked\FigureRenderer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -37,6 +37,9 @@ namespace LuaScript.Tests
|
||||
[InlineData("local pd = obj.getpixeldata()", "Native")]
|
||||
[InlineData("--!moonsharp\nobj.setpixel(0,0,1,1,1)", "MoonSharp")]
|
||||
[InlineData("--!native\nobj.rz = 1", "Native")]
|
||||
[InlineData("obj.load(\"figure\", \"円\", 0xff0000, 100)", "MoonSharp")]
|
||||
[InlineData("obj.load(\"figure\", \"円\", 0xff0000, 100)\nlocal r = obj.getpixel(0,0)", "MoonSharp")]
|
||||
[InlineData("--!native\nobj.load(\"figure\", \"円\", 0xff0000, 100)", "Native")]
|
||||
public void ResolveAuto_RoutesPixelScriptsToNative(string script, string expected)
|
||||
{
|
||||
Assert.Equal(expected, ScriptDirective.ResolveAuto(script).ToString());
|
||||
|
||||
@@ -29,6 +29,14 @@ namespace LuaScript
|
||||
public double Track2 { get; set; }
|
||||
public double Track3 { get; set; }
|
||||
|
||||
public bool Check0 { get; set; }
|
||||
public bool Check1 { get; set; }
|
||||
public bool Check2 { get; set; }
|
||||
public bool Check3 { get; set; }
|
||||
|
||||
public bool HasColor { get; set; }
|
||||
public double ColorValue { get; set; }
|
||||
|
||||
public double Time { get; set; }
|
||||
public int Frame { get; set; }
|
||||
public int TotalFrame { get; set; }
|
||||
@@ -63,8 +71,10 @@ namespace LuaScript
|
||||
private byte[]? _pixelBuffer;
|
||||
private bool _pixelBufferLoaded;
|
||||
private bool _isPixelsDirty;
|
||||
private bool _bufferReplaced;
|
||||
|
||||
public bool IsPixelsDirty => _isPixelsDirty;
|
||||
public bool BufferReplaced => _bufferReplaced;
|
||||
|
||||
internal int TotalChannels => ImageWidth * ImageHeight * 4;
|
||||
|
||||
@@ -76,6 +86,17 @@ namespace LuaScript
|
||||
_pixelBuffer = null;
|
||||
_pixelBufferLoaded = false;
|
||||
_isPixelsDirty = false;
|
||||
_bufferReplaced = false;
|
||||
}
|
||||
|
||||
internal void ReplaceBuffer(byte[] buffer, int width, int height)
|
||||
{
|
||||
_pixelBuffer = buffer;
|
||||
_pixelBufferLoaded = true;
|
||||
_isPixelsDirty = true;
|
||||
_bufferReplaced = true;
|
||||
ImageWidth = width;
|
||||
ImageHeight = height;
|
||||
}
|
||||
|
||||
internal void EnsurePixelBuffer()
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal sealed class AviUtlParameterLayout
|
||||
{
|
||||
public const int MaxTracks = 4;
|
||||
public const int MaxChecks = 4;
|
||||
|
||||
public readonly record struct TrackParam(int Index, string Name, double Min, double Max, double Default, double Step);
|
||||
public readonly record struct CheckParam(int Index, string Name, bool Default);
|
||||
public readonly record struct ColorParam(int Default);
|
||||
|
||||
private readonly TrackParam?[] _tracks = new TrackParam?[MaxTracks];
|
||||
private readonly CheckParam?[] _checks = new CheckParam?[MaxChecks];
|
||||
|
||||
public static readonly AviUtlParameterLayout Empty = new();
|
||||
|
||||
public TrackParam? GetTrack(int index) => (uint)index < MaxTracks ? _tracks[index] : null;
|
||||
public CheckParam? GetCheck(int index) => (uint)index < MaxChecks ? _checks[index] : null;
|
||||
public ColorParam? Color { get; private set; }
|
||||
|
||||
public bool HasTrack(int index) => GetTrack(index).HasValue;
|
||||
public bool HasCheck(int index) => GetCheck(index).HasValue;
|
||||
public bool HasColor => Color.HasValue;
|
||||
|
||||
public bool HasAny
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < MaxTracks; i++)
|
||||
if (_tracks[i].HasValue) return true;
|
||||
for (int i = 0; i < MaxChecks; i++)
|
||||
if (_checks[i].HasValue) return true;
|
||||
return HasColor;
|
||||
}
|
||||
}
|
||||
|
||||
public static AviUtlParameterLayout Parse(string? source)
|
||||
{
|
||||
var layout = new AviUtlParameterLayout();
|
||||
if (string.IsNullOrEmpty(source))
|
||||
return layout;
|
||||
|
||||
var lines = source.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
|
||||
int sectionStart = 0;
|
||||
int sectionEnd = lines.Length;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (!IsSectionHeader(lines[i]))
|
||||
continue;
|
||||
sectionStart = i + 1;
|
||||
sectionEnd = lines.Length;
|
||||
for (int j = sectionStart; j < lines.Length; j++)
|
||||
{
|
||||
if (IsSectionHeader(lines[j]))
|
||||
{
|
||||
sectionEnd = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = sectionStart; i < sectionEnd; i++)
|
||||
layout.ParseLine(lines[i]);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void ParseLine(string line)
|
||||
{
|
||||
int i = SkipSpaces(line, 0);
|
||||
if (i + 1 >= line.Length || line[i] != '-' || line[i + 1] != '-')
|
||||
return;
|
||||
i += 2;
|
||||
if (i < line.Length && line[i] == '!')
|
||||
return;
|
||||
|
||||
int nameStart = i;
|
||||
while (i < line.Length && IsNameChar(line[i]))
|
||||
i++;
|
||||
if (i >= line.Length || line[i] != ':')
|
||||
return;
|
||||
|
||||
string name = line.Substring(nameStart, i - nameStart);
|
||||
string content = line.Substring(i + 1);
|
||||
|
||||
if (name.StartsWith("track", StringComparison.OrdinalIgnoreCase) &&
|
||||
TryGetIndex(name, 5, MaxTracks, out int trackIndex))
|
||||
{
|
||||
ParseTrack(trackIndex, content);
|
||||
}
|
||||
else if (name.StartsWith("check", StringComparison.OrdinalIgnoreCase) &&
|
||||
TryGetIndex(name, 5, MaxChecks, out int checkIndex))
|
||||
{
|
||||
ParseCheck(checkIndex, content);
|
||||
}
|
||||
else if (name.Equals("color", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ParseColor(content);
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseTrack(int index, string content)
|
||||
{
|
||||
var parts = content.Split(',');
|
||||
string trackName = parts.Length > 0 ? parts[0].Trim() : string.Empty;
|
||||
double min = ParseNumber(parts, 1, 0d);
|
||||
double max = ParseNumber(parts, 2, 100d);
|
||||
double def = ParseNumber(parts, 3, min);
|
||||
double step = ParseNumber(parts, 4, 0d);
|
||||
if (max < min)
|
||||
(min, max) = (max, min);
|
||||
def = Math.Clamp(def, min, max);
|
||||
_tracks[index] = new TrackParam(index, trackName, min, max, def, step);
|
||||
}
|
||||
|
||||
private void ParseCheck(int index, string content)
|
||||
{
|
||||
var parts = content.Split(',');
|
||||
string checkName = parts.Length > 0 ? parts[0].Trim() : string.Empty;
|
||||
double def = ParseNumber(parts, 1, 0d);
|
||||
_checks[index] = new CheckParam(index, checkName, def != 0d);
|
||||
}
|
||||
|
||||
private void ParseColor(string content)
|
||||
{
|
||||
string token = FirstToken(content);
|
||||
if (TryParseColorLiteral(token, out int rgb))
|
||||
Color = new ColorParam(rgb);
|
||||
}
|
||||
|
||||
private static bool TryGetIndex(string name, int start, int max, out int index)
|
||||
{
|
||||
index = -1;
|
||||
if (name.Length != start + 1)
|
||||
return false;
|
||||
char c = name[start];
|
||||
if (c < '0' || c > '9')
|
||||
return false;
|
||||
int value = c - '0';
|
||||
if (value >= max)
|
||||
return false;
|
||||
index = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static double ParseNumber(string[] parts, int idx, double fallback)
|
||||
{
|
||||
if (idx >= parts.Length)
|
||||
return fallback;
|
||||
string token = parts[idx].Trim();
|
||||
return double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out double value)
|
||||
? value
|
||||
: fallback;
|
||||
}
|
||||
|
||||
private static bool TryParseColorLiteral(string token, out int rgb)
|
||||
{
|
||||
rgb = 0;
|
||||
if (token.Length == 0)
|
||||
return false;
|
||||
if (token.StartsWith("0x", StringComparison.OrdinalIgnoreCase) || token.StartsWith("0X", StringComparison.Ordinal))
|
||||
{
|
||||
if (token.Length <= 2)
|
||||
return false;
|
||||
return int.TryParse(token.AsSpan(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out rgb);
|
||||
}
|
||||
return int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out rgb);
|
||||
}
|
||||
|
||||
private static string FirstToken(string content)
|
||||
{
|
||||
int start = SkipSpaces(content, 0);
|
||||
int i = start;
|
||||
while (i < content.Length && content[i] != ',' && content[i] != ' ' && content[i] != '\t')
|
||||
i++;
|
||||
return content.Substring(start, i - start);
|
||||
}
|
||||
|
||||
private static bool IsSectionHeader(string line)
|
||||
{
|
||||
int i = SkipSpaces(line, 0);
|
||||
return i < line.Length && line[i] == '@';
|
||||
}
|
||||
|
||||
private static int SkipSpaces(string text, int index)
|
||||
{
|
||||
while (index < text.Length && (text[index] == ' ' || text[index] == '\t'))
|
||||
index++;
|
||||
return index;
|
||||
}
|
||||
|
||||
private static bool IsNameChar(char c) =>
|
||||
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal static class AviUtlRandom
|
||||
{
|
||||
public static double Next(double a, double b, double seed, double frame)
|
||||
{
|
||||
long seedBits = BitConverter.DoubleToInt64Bits(seed);
|
||||
long frameBits = BitConverter.DoubleToInt64Bits(frame);
|
||||
uint s = (uint)(seedBits ^ (seedBits >> 32));
|
||||
uint f = (uint)(frameBits ^ (frameBits >> 32));
|
||||
|
||||
uint h = s * 374761393u + f * 668265263u;
|
||||
h = (h ^ (h >> 13)) * 1274126177u;
|
||||
h ^= h >> 16;
|
||||
|
||||
double r = h / 4294967295.0;
|
||||
|
||||
long lo = (long)Math.Floor(Math.Min(a, b));
|
||||
long hi = (long)Math.Floor(Math.Max(a, b));
|
||||
long span = hi - lo + 1L;
|
||||
if (span <= 1L)
|
||||
return lo;
|
||||
|
||||
long value = lo + (long)(r * span);
|
||||
return value > hi ? hi : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal static class AviUtlScript
|
||||
{
|
||||
private enum DirectiveKind
|
||||
{
|
||||
None,
|
||||
Dialog,
|
||||
Param,
|
||||
}
|
||||
|
||||
public static string Transform(string source)
|
||||
{
|
||||
if (string.IsNullOrEmpty(source))
|
||||
return source;
|
||||
|
||||
var lines = source.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
|
||||
int sectionStart = 0;
|
||||
int sectionEnd = lines.Length;
|
||||
bool hasSection = false;
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (!IsSectionHeader(lines[i]))
|
||||
continue;
|
||||
|
||||
hasSection = true;
|
||||
sectionStart = i + 1;
|
||||
sectionEnd = lines.Length;
|
||||
for (int j = sectionStart; j < lines.Length; j++)
|
||||
{
|
||||
if (IsSectionHeader(lines[j]))
|
||||
{
|
||||
sectionEnd = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var prelude = new List<string>();
|
||||
for (int i = sectionStart; i < sectionEnd; i++)
|
||||
AppendDeclarations(lines[i], prelude);
|
||||
|
||||
if (!hasSection && prelude.Count == 0)
|
||||
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');
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static bool IsSectionHeader(string line)
|
||||
{
|
||||
int i = SkipSpaces(line, 0);
|
||||
return i < line.Length && line[i] == '@';
|
||||
}
|
||||
|
||||
private static void AppendDeclarations(string line, List<string> prelude)
|
||||
{
|
||||
int i = SkipSpaces(line, 0);
|
||||
if (i + 1 >= line.Length || line[i] != '-' || line[i + 1] != '-')
|
||||
return;
|
||||
i += 2;
|
||||
if (i < line.Length && line[i] == '!')
|
||||
return;
|
||||
|
||||
int nameStart = i;
|
||||
while (i < line.Length && IsNameChar(line[i]))
|
||||
i++;
|
||||
if (i >= line.Length || line[i] != ':')
|
||||
return;
|
||||
|
||||
string name = line.Substring(nameStart, i - nameStart);
|
||||
string content = line.Substring(i + 1);
|
||||
|
||||
switch (Classify(name))
|
||||
{
|
||||
case DirectiveKind.Dialog:
|
||||
AppendDialog(content, prelude);
|
||||
break;
|
||||
case DirectiveKind.Param:
|
||||
AppendParam(content, prelude);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static DirectiveKind Classify(string name)
|
||||
{
|
||||
if (name.Equals("dialog", StringComparison.OrdinalIgnoreCase))
|
||||
return DirectiveKind.Dialog;
|
||||
if (name.Equals("param", StringComparison.OrdinalIgnoreCase))
|
||||
return DirectiveKind.Param;
|
||||
return DirectiveKind.None;
|
||||
}
|
||||
|
||||
private static void AppendDialog(string content, List<string> prelude)
|
||||
{
|
||||
foreach (var segment in content.Split(';'))
|
||||
{
|
||||
string trimmed = segment.Trim();
|
||||
if (trimmed.Length == 0)
|
||||
continue;
|
||||
int comma = trimmed.IndexOf(',');
|
||||
if (comma < 0)
|
||||
continue;
|
||||
string declaration = trimmed.Substring(comma + 1).Trim();
|
||||
if (declaration.Length != 0)
|
||||
prelude.Add(declaration);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AppendParam(string content, List<string> prelude)
|
||||
{
|
||||
string trimmed = content.Trim();
|
||||
if (trimmed.Length != 0)
|
||||
prelude.Add(trimmed);
|
||||
}
|
||||
|
||||
private static int SkipSpaces(string text, int index)
|
||||
{
|
||||
while (index < text.Length && (text[index] == ' ' || text[index] == '\t'))
|
||||
index++;
|
||||
return index;
|
||||
}
|
||||
|
||||
private static bool IsNameChar(char c) =>
|
||||
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal static class FigureRenderer
|
||||
{
|
||||
private enum Shape
|
||||
{
|
||||
Ellipse,
|
||||
Rectangle,
|
||||
Triangle,
|
||||
Pentagon,
|
||||
Hexagon,
|
||||
Star,
|
||||
}
|
||||
|
||||
public static byte[] Render(string name, int width, int height, int colorRgb, double lineWidth)
|
||||
{
|
||||
width = Math.Max(1, width);
|
||||
height = Math.Max(1, height);
|
||||
var buffer = new byte[width * height * 4];
|
||||
|
||||
Shape shape = Resolve(name);
|
||||
double hx = width / 2d;
|
||||
double hy = height / 2d;
|
||||
|
||||
double r = (colorRgb >> 16) & 0xFF;
|
||||
double g = (colorRgb >> 8) & 0xFF;
|
||||
double b = colorRgb & 0xFF;
|
||||
|
||||
(double X, double Y)[]? polygon = shape switch
|
||||
{
|
||||
Shape.Triangle => RegularPolygon(3, hx, hy),
|
||||
Shape.Pentagon => RegularPolygon(5, hx, hy),
|
||||
Shape.Hexagon => RegularPolygon(6, hx, hy),
|
||||
Shape.Star => StarPolygon(hx, hy),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
bool filled = lineWidth <= 0d;
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
double py = y + 0.5 - hy;
|
||||
int row = y * width * 4;
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
double px = x + 0.5 - hx;
|
||||
double d = shape switch
|
||||
{
|
||||
Shape.Ellipse => EllipseSdf(px, py, hx, hy),
|
||||
Shape.Rectangle => BoxSdf(px, py, hx, hy),
|
||||
_ => PolygonSdf(px, py, polygon!),
|
||||
};
|
||||
if (!filled)
|
||||
d = Math.Max(d, -d - lineWidth);
|
||||
|
||||
double coverage = 0.5 - d;
|
||||
if (coverage <= 0d)
|
||||
continue;
|
||||
if (coverage > 1d)
|
||||
coverage = 1d;
|
||||
|
||||
int i = row + x * 4;
|
||||
buffer[i] = ToByte(b * coverage);
|
||||
buffer[i + 1] = ToByte(g * coverage);
|
||||
buffer[i + 2] = ToByte(r * coverage);
|
||||
buffer[i + 3] = ToByte(255d * coverage);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static Shape Resolve(string name)
|
||||
{
|
||||
switch (name.Trim())
|
||||
{
|
||||
case "円":
|
||||
case "楕円":
|
||||
case "circle":
|
||||
case "ellipse":
|
||||
return Shape.Ellipse;
|
||||
case "三角形":
|
||||
case "triangle":
|
||||
return Shape.Triangle;
|
||||
case "五角形":
|
||||
case "pentagon":
|
||||
return Shape.Pentagon;
|
||||
case "六角形":
|
||||
case "hexagon":
|
||||
return Shape.Hexagon;
|
||||
case "星形":
|
||||
case "star":
|
||||
return Shape.Star;
|
||||
default:
|
||||
return Shape.Rectangle;
|
||||
}
|
||||
}
|
||||
|
||||
private static (double X, double Y)[] RegularPolygon(int sides, double hx, double hy)
|
||||
{
|
||||
var vertices = new (double X, double Y)[sides];
|
||||
for (int k = 0; k < sides; k++)
|
||||
{
|
||||
double angle = -Math.PI / 2d + 2d * Math.PI * k / sides;
|
||||
vertices[k] = (Math.Cos(angle) * hx, Math.Sin(angle) * hy);
|
||||
}
|
||||
return vertices;
|
||||
}
|
||||
|
||||
private static (double X, double Y)[] StarPolygon(double hx, double hy)
|
||||
{
|
||||
const double innerRatio = 0.38196601125010515d;
|
||||
var vertices = new (double X, double Y)[10];
|
||||
for (int k = 0; k < 10; k++)
|
||||
{
|
||||
double angle = -Math.PI / 2d + Math.PI * k / 5d;
|
||||
double radius = (k & 1) == 0 ? 1d : innerRatio;
|
||||
vertices[k] = (Math.Cos(angle) * hx * radius, Math.Sin(angle) * hy * radius);
|
||||
}
|
||||
return vertices;
|
||||
}
|
||||
|
||||
private static double EllipseSdf(double px, double py, double ax, double ay)
|
||||
{
|
||||
if (ax <= 0d || ay <= 0d)
|
||||
return double.MaxValue;
|
||||
double kx = px / ax;
|
||||
double ky = py / ay;
|
||||
double k1 = Math.Sqrt(kx * kx + ky * ky);
|
||||
if (k1 == 0d)
|
||||
return -Math.Min(ax, ay);
|
||||
double nx = kx / ax;
|
||||
double ny = ky / ay;
|
||||
double k2 = Math.Sqrt(nx * nx + ny * ny);
|
||||
return k1 * (k1 - 1d) / k2;
|
||||
}
|
||||
|
||||
private static double BoxSdf(double px, double py, double hx, double hy)
|
||||
{
|
||||
double qx = Math.Abs(px) - hx;
|
||||
double qy = Math.Abs(py) - hy;
|
||||
double ox = Math.Max(qx, 0d);
|
||||
double oy = Math.Max(qy, 0d);
|
||||
return Math.Sqrt(ox * ox + oy * oy) + Math.Min(Math.Max(qx, qy), 0d);
|
||||
}
|
||||
|
||||
private static double PolygonSdf(double px, double py, (double X, double Y)[] v)
|
||||
{
|
||||
int n = v.Length;
|
||||
double dx = px - v[0].X;
|
||||
double dy = py - v[0].Y;
|
||||
double d = dx * dx + dy * dy;
|
||||
double s = 1d;
|
||||
|
||||
for (int i = 0, j = n - 1; i < n; j = i, i++)
|
||||
{
|
||||
double ex = v[j].X - v[i].X;
|
||||
double ey = v[j].Y - v[i].Y;
|
||||
double wx = px - v[i].X;
|
||||
double wy = py - v[i].Y;
|
||||
double t = Clamp((wx * ex + wy * ey) / (ex * ex + ey * ey), 0d, 1d);
|
||||
double bx = wx - ex * t;
|
||||
double by = wy - ey * t;
|
||||
d = Math.Min(d, bx * bx + by * by);
|
||||
|
||||
bool c1 = py >= v[i].Y;
|
||||
bool c2 = py < v[j].Y;
|
||||
bool c3 = ex * wy > ey * wx;
|
||||
if ((c1 && c2 && c3) || (!c1 && !c2 && !c3))
|
||||
s = -s;
|
||||
}
|
||||
|
||||
return s * Math.Sqrt(d);
|
||||
}
|
||||
|
||||
private static double Clamp(double v, double lo, double hi)
|
||||
{
|
||||
if (v < lo) return lo;
|
||||
if (v > hi) return hi;
|
||||
return v;
|
||||
}
|
||||
|
||||
private static byte ToByte(double v)
|
||||
{
|
||||
int i = (int)(v + 0.5d);
|
||||
if (i < 0) return 0;
|
||||
if (i > 255) return 255;
|
||||
return (byte)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,11 @@ namespace LuaScript.Engine
|
||||
f[NativeProtocol.Track1] = ctx.Track1;
|
||||
f[NativeProtocol.Track2] = ctx.Track2;
|
||||
f[NativeProtocol.Track3] = ctx.Track3;
|
||||
f[NativeProtocol.Check0] = ctx.Check0 ? 1d : 0d;
|
||||
f[NativeProtocol.Check1] = ctx.Check1 ? 1d : 0d;
|
||||
f[NativeProtocol.Check2] = ctx.Check2 ? 1d : 0d;
|
||||
f[NativeProtocol.Check3] = ctx.Check3 ? 1d : 0d;
|
||||
f[NativeProtocol.Color] = ctx.HasColor ? ctx.ColorValue : -1d;
|
||||
f[NativeProtocol.Time] = ctx.Time;
|
||||
f[NativeProtocol.Frame] = ctx.Frame;
|
||||
f[NativeProtocol.TotalFrame] = ctx.TotalFrame;
|
||||
|
||||
@@ -104,6 +104,11 @@ namespace LuaScript.Engine
|
||||
public const int IsPaused = 50;
|
||||
public const int TimelineFrame = 51;
|
||||
public const int TimelineTime = 52;
|
||||
public const int Check0 = 53;
|
||||
public const int Check1 = 54;
|
||||
public const int Check2 = 55;
|
||||
public const int Check3 = 56;
|
||||
public const int Color = 57;
|
||||
|
||||
public const int FirstWritableField = X;
|
||||
public const int LastWritableField = Rzr;
|
||||
|
||||
@@ -19,12 +19,22 @@ namespace LuaScript.Engine
|
||||
{
|
||||
if (TryGetDirective(script, out var kind))
|
||||
return kind;
|
||||
if (UsesDrawingApi(script))
|
||||
return ScriptEngineKind.MoonSharp;
|
||||
return UsesPixelApi(script) ? ScriptEngineKind.Native : ScriptEngineKind.MoonSharp;
|
||||
}
|
||||
|
||||
public static bool UsesPixelApi(string? script) =>
|
||||
script is not null && (script.Contains("getpixel", StringComparison.Ordinal) || script.Contains("setpixel", StringComparison.Ordinal));
|
||||
|
||||
public static bool UsesDrawingApi(string? script) =>
|
||||
script is not null && (
|
||||
script.Contains("obj.load", StringComparison.Ordinal) ||
|
||||
script.Contains("obj.draw", StringComparison.Ordinal) ||
|
||||
script.Contains("obj.effect", StringComparison.Ordinal) ||
|
||||
script.Contains("obj.setoption", StringComparison.Ordinal) ||
|
||||
script.Contains("obj.copybuffer", StringComparison.Ordinal));
|
||||
|
||||
private static bool TryGetDirective(string? script, out ScriptEngineKind kind)
|
||||
{
|
||||
kind = ScriptEngineKind.MoonSharp;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace LuaScript
|
||||
"obj.time", "obj.totaltime", "obj.t", "obj.frame", "obj.totalframe",
|
||||
"obj.framerate", "obj.layer", "obj.index", "obj.num",
|
||||
"obj.getpixel", "obj.setpixel",
|
||||
"obj.getpixeldata"
|
||||
"obj.getpixeldata", "obj.rand", "obj.load"
|
||||
]),
|
||||
("math", [
|
||||
"math.abs", "math.ceil", "math.cos", "math.exp", "math.floor",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>1.3.4</Version>
|
||||
<Version>1.6.0</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
+104
-1
@@ -1,8 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Windows.Media;
|
||||
using LuaScript.Compat;
|
||||
using Newtonsoft.Json;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Controls;
|
||||
using YukkuriMovieMaker.Exo;
|
||||
using YukkuriMovieMaker.ItemEditor.CustomVisibilityAttributes;
|
||||
using YukkuriMovieMaker.Player.Video;
|
||||
using YukkuriMovieMaker.Plugin;
|
||||
using YukkuriMovieMaker.Plugin.Effects;
|
||||
@@ -27,27 +31,126 @@ namespace LuaScript
|
||||
|
||||
[Display(GroupName = nameof(Texts.ScriptGroup), ResourceType = typeof(Texts))]
|
||||
[CodeEditor(Language = "pack://application:,,,/LuaScript;component/Resources/SyntaxDefinitions/Lua-{theme}.xshd", FoldingStrategyType = typeof(LuaFoldingStrategy), AutoCompletionStrategyType = typeof(LuaAutoCompletionStrategy), ToolBarStrategyType = typeof(EmptyToolBarStrategy), PropertyEditorSize = PropertyEditorSize.FullWidth)]
|
||||
public string Script { get => _script; set => Set(ref _script, value); }
|
||||
public string Script
|
||||
{
|
||||
get => _script;
|
||||
set { if (Set(ref _script, value)) UpdateLayout(); }
|
||||
}
|
||||
string _script = DefaultScript;
|
||||
|
||||
string IScriptProvider.DefaultScript => DefaultScript;
|
||||
|
||||
internal AviUtlParameterLayout Layout { get; private set; } = AviUtlParameterLayout.Parse(DefaultScript);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Track0), Description = nameof(Texts.TrackDesc), ResourceType = typeof(Texts))]
|
||||
[AnimationSlider("F2", "", -100, 100)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack0Visible), true)]
|
||||
public Animation Track0 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Track1), Description = nameof(Texts.TrackDesc), ResourceType = typeof(Texts))]
|
||||
[AnimationSlider("F2", "", -100, 100)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack1Visible), true)]
|
||||
public Animation Track1 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Track2), Description = nameof(Texts.TrackDesc), ResourceType = typeof(Texts))]
|
||||
[AnimationSlider("F2", "", -100, 100)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack2Visible), true)]
|
||||
public Animation Track2 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Track3), Description = nameof(Texts.TrackDesc), ResourceType = typeof(Texts))]
|
||||
[AnimationSlider("F2", "", -100, 100)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack3Visible), true)]
|
||||
public Animation Track3 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check0), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck0Visible), true)]
|
||||
public bool Check0 { get => _check0; set => Set(ref _check0, value); }
|
||||
bool _check0;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check1), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck1Visible), true)]
|
||||
public bool Check1 { get => _check1; set => Set(ref _check1, value); }
|
||||
bool _check1;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check2), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck2Visible), true)]
|
||||
public bool Check2 { get => _check2; set => Set(ref _check2, value); }
|
||||
bool _check2;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check3), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck3Visible), true)]
|
||||
public bool Check3 { get => _check3; set => Set(ref _check3, value); }
|
||||
bool _check3;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Color), Description = nameof(Texts.ColorDesc), ResourceType = typeof(Texts))]
|
||||
[ColorPicker]
|
||||
[ShowPropertyEditorWhen(nameof(IsColorVisible), true)]
|
||||
public Color Color { get => _color; set => Set(ref _color, value); }
|
||||
Color _color = Colors.White;
|
||||
|
||||
[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); }
|
||||
[JsonIgnore] public bool IsTrack3Visible { get => _isTrack3Visible; private set => Set(ref _isTrack3Visible, value); }
|
||||
[JsonIgnore] public bool IsCheck0Visible { get => _isCheck0Visible; private set => Set(ref _isCheck0Visible, value); }
|
||||
[JsonIgnore] public bool IsCheck1Visible { get => _isCheck1Visible; private set => Set(ref _isCheck1Visible, value); }
|
||||
[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); }
|
||||
|
||||
bool _isTrack0Visible = true;
|
||||
bool _isTrack1Visible = true;
|
||||
bool _isTrack2Visible = true;
|
||||
bool _isTrack3Visible = true;
|
||||
bool _isCheck0Visible;
|
||||
bool _isCheck1Visible;
|
||||
bool _isCheck2Visible;
|
||||
bool _isCheck3Visible;
|
||||
bool _isColorVisible;
|
||||
|
||||
private void UpdateLayout()
|
||||
{
|
||||
var layout = AviUtlParameterLayout.Parse(_script);
|
||||
Layout = layout;
|
||||
|
||||
bool hasAny = layout.HasAny;
|
||||
|
||||
IsTrack0Visible = !hasAny || layout.HasTrack(0);
|
||||
IsTrack1Visible = !hasAny || layout.HasTrack(1);
|
||||
IsTrack2Visible = !hasAny || layout.HasTrack(2);
|
||||
IsTrack3Visible = !hasAny || layout.HasTrack(3);
|
||||
IsCheck0Visible = layout.HasCheck(0);
|
||||
IsCheck1Visible = layout.HasCheck(1);
|
||||
IsCheck2Visible = layout.HasCheck(2);
|
||||
IsCheck3Visible = layout.HasCheck(3);
|
||||
IsColorVisible = layout.HasColor;
|
||||
|
||||
SeedDefaults(layout);
|
||||
}
|
||||
|
||||
private void SeedDefaults(AviUtlParameterLayout layout)
|
||||
{
|
||||
if (layout.GetCheck(0) is { Default: true } && !_check0) Check0 = true;
|
||||
if (layout.GetCheck(1) is { Default: true } && !_check1) Check1 = true;
|
||||
if (layout.GetCheck(2) is { Default: true } && !_check2) Check2 = true;
|
||||
if (layout.GetCheck(3) is { Default: true } && !_check3) Check3 = true;
|
||||
|
||||
if (layout.Color is { } color && _color == Colors.White)
|
||||
Color = ToMediaColor(color.Default);
|
||||
}
|
||||
|
||||
private static Color ToMediaColor(int rgb)
|
||||
{
|
||||
byte r = (byte)((rgb >> 16) & 0xFF);
|
||||
byte g = (byte)((rgb >> 8) & 0xFF);
|
||||
byte b = (byte)(rgb & 0xFF);
|
||||
return Color.FromRgb(r, g, b);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> CreateExoVideoFilters(int keyFrameIndex, ExoOutputDescription exoOutputDescription) => [];
|
||||
|
||||
public override IVideoEffectProcessor CreateVideoEffect(IGraphicsDevicesAndContext devices)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LuaScript.Compat;
|
||||
using LuaScript.Engine;
|
||||
using Vortice;
|
||||
using Vortice.DCommon;
|
||||
@@ -27,6 +28,12 @@ namespace LuaScript
|
||||
double Track1,
|
||||
double Track2,
|
||||
double Track3,
|
||||
bool Check0,
|
||||
bool Check1,
|
||||
bool Check2,
|
||||
bool Check3,
|
||||
bool HasColor,
|
||||
int Color,
|
||||
string Script,
|
||||
TimelineSourceUsage Usage,
|
||||
Guid SceneId,
|
||||
@@ -77,6 +84,9 @@ namespace LuaScript
|
||||
private RawRectF _cachedBounds;
|
||||
|
||||
private bool _isFirst = true;
|
||||
private string _sourceScript = string.Empty;
|
||||
private string _runnableScript = string.Empty;
|
||||
private bool _runnableCached;
|
||||
private ID2D1Image? _cachedInput;
|
||||
private RenderKey _cachedKey;
|
||||
private SceneObjectQuery[] _cachedQueries = [];
|
||||
@@ -112,6 +122,17 @@ namespace LuaScript
|
||||
return _lastSceneId;
|
||||
}
|
||||
|
||||
private string GetRunnableScript(string source)
|
||||
{
|
||||
if (_runnableCached && string.Equals(source, _sourceScript, StringComparison.Ordinal))
|
||||
return _runnableScript;
|
||||
|
||||
_runnableScript = AviUtlScript.Transform(source);
|
||||
_sourceScript = source;
|
||||
_runnableCached = true;
|
||||
return _runnableScript;
|
||||
}
|
||||
|
||||
protected override void setInput(ID2D1Image? input)
|
||||
{
|
||||
if (!ReferenceEquals(_cachedInput, input))
|
||||
@@ -135,16 +156,22 @@ namespace LuaScript
|
||||
var time = desc.ItemPosition.Time.TotalSeconds;
|
||||
var script = item.Script ?? string.Empty;
|
||||
|
||||
var t0 = item.Track0.GetValue(frame, length, fps);
|
||||
var t1 = item.Track1.GetValue(frame, length, fps);
|
||||
var t2 = item.Track2.GetValue(frame, length, fps);
|
||||
var t3 = item.Track3.GetValue(frame, length, fps);
|
||||
var layout = item.Layout;
|
||||
var t0 = ClampTrack(item.Track0.GetValue(frame, length, fps), layout, 0);
|
||||
var t1 = ClampTrack(item.Track1.GetValue(frame, length, fps), layout, 1);
|
||||
var t2 = ClampTrack(item.Track2.GetValue(frame, length, fps), layout, 2);
|
||||
var t3 = ClampTrack(item.Track3.GetValue(frame, length, fps), layout, 3);
|
||||
|
||||
bool c0 = item.Check0, c1 = item.Check1, c2 = item.Check2, c3 = item.Check3;
|
||||
bool hasColor = layout.HasColor;
|
||||
int colorRgb = hasColor ? (item.Color.R << 16) | (item.Color.G << 8) | item.Color.B : 0;
|
||||
|
||||
var inDesc = desc.DrawDescription;
|
||||
|
||||
var key = new RenderKey(
|
||||
frame, time, length, fps,
|
||||
t0, t1, t2, t3,
|
||||
c0, c1, c2, c3, hasColor, colorRgb,
|
||||
script, desc.Usage, desc.SceneId,
|
||||
desc.TimelinePosition.Frame,
|
||||
desc.TimelinePosition.Time.TotalSeconds,
|
||||
@@ -179,24 +206,30 @@ namespace LuaScript
|
||||
|
||||
try
|
||||
{
|
||||
bool wantNative = ScriptDirective.ResolveAuto(script) == ScriptEngineKind.Native;
|
||||
string runnable = GetRunnableScript(script);
|
||||
bool wantNative = ScriptDirective.ResolveAuto(runnable) == ScriptEngineKind.Native;
|
||||
bool nativeReady = wantNative && LuaJitWorker.IsAvailable(NativeDirectory);
|
||||
if (wantNative && !nativeReady)
|
||||
WarnNativeUnavailableOnce();
|
||||
|
||||
if (nativeReady)
|
||||
{
|
||||
pixelsModified = ExecuteNative(script, ctx, bounds, imgW, imgH);
|
||||
pixelsModified = ExecuteNative(runnable, ctx, bounds, imgW, imgH);
|
||||
}
|
||||
else
|
||||
{
|
||||
_engine.Execute(script, ctx);
|
||||
_engine.Execute(runnable, ctx);
|
||||
|
||||
if (ctx.IsPixelsDirty)
|
||||
{
|
||||
EnsureBitmaps(imgW, imgH);
|
||||
WritePixelsToOutput(ctx.GetPixelBuffer()!, imgW);
|
||||
UpdateTransformEffect(bounds);
|
||||
int bufW = ctx.ImageWidth;
|
||||
int bufH = ctx.ImageHeight;
|
||||
EnsureBitmaps(bufW, bufH);
|
||||
WritePixelsToOutput(ctx.GetPixelBuffer()!, bufW);
|
||||
if (ctx.BufferReplaced)
|
||||
UpdateTransformEffect(-bufW / 2f, -bufH / 2f);
|
||||
else
|
||||
UpdateTransformEffect(bounds.Left, bounds.Top);
|
||||
effectOutput = _transformEffect!.Output;
|
||||
pixelsModified = true;
|
||||
}
|
||||
@@ -314,6 +347,12 @@ namespace LuaScript
|
||||
ctx.Track1 = key.Track1;
|
||||
ctx.Track2 = key.Track2;
|
||||
ctx.Track3 = key.Track3;
|
||||
ctx.Check0 = key.Check0;
|
||||
ctx.Check1 = key.Check1;
|
||||
ctx.Check2 = key.Check2;
|
||||
ctx.Check3 = key.Check3;
|
||||
ctx.HasColor = key.HasColor;
|
||||
ctx.ColorValue = key.Color;
|
||||
ctx.Time = key.Time;
|
||||
ctx.Frame = key.Frame;
|
||||
ctx.TotalFrame = key.Length;
|
||||
@@ -337,6 +376,11 @@ namespace LuaScript
|
||||
ctx.TimeRatio = key.Length > 0 ? key.Frame / (double)key.Length : 0d;
|
||||
}
|
||||
|
||||
private static double ClampTrack(double value, AviUtlParameterLayout layout, int index)
|
||||
{
|
||||
return layout.GetTrack(index) is { } p ? Math.Clamp(value, p.Min, p.Max) : value;
|
||||
}
|
||||
|
||||
private static DrawDescription BuildOutputDesc(DrawDescription inDesc, AviUtlScriptContext ctx)
|
||||
{
|
||||
return inDesc with
|
||||
@@ -382,7 +426,7 @@ namespace LuaScript
|
||||
{
|
||||
EnsureBitmaps(imgW, imgH);
|
||||
WritePixelsToOutput(buffer, imgW);
|
||||
UpdateTransformEffect(bounds);
|
||||
UpdateTransformEffect(bounds.Left, bounds.Top);
|
||||
effectOutput = _transformEffect!.Output;
|
||||
return true;
|
||||
}
|
||||
@@ -446,7 +490,7 @@ namespace LuaScript
|
||||
_outputBitmap!.CopyFromMemory(new nint(ptr), width * 4);
|
||||
}
|
||||
|
||||
private void UpdateTransformEffect(RawRectF bounds)
|
||||
private void UpdateTransformEffect(float left, float top)
|
||||
{
|
||||
if (_transformEffect is null)
|
||||
{
|
||||
@@ -455,10 +499,10 @@ namespace LuaScript
|
||||
_cachedBounds = default;
|
||||
}
|
||||
|
||||
if (_cachedBounds.Left != bounds.Left || _cachedBounds.Top != bounds.Top)
|
||||
if (_cachedBounds.Left != left || _cachedBounds.Top != top)
|
||||
{
|
||||
_transformEffect.TransformMatrix = Matrix3x2.CreateTranslation(bounds.Left, bounds.Top);
|
||||
_cachedBounds = bounds;
|
||||
_transformEffect.TransformMatrix = Matrix3x2.CreateTranslation(left, top);
|
||||
_cachedBounds = new RawRectF(left, top, left, top);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using LuaScript.Compat;
|
||||
using MoonSharp.Interpreter;
|
||||
using MoonSharp.Interpreter.Debugging;
|
||||
using MoonSharp.Interpreter.Loaders;
|
||||
@@ -312,6 +313,12 @@ namespace LuaScript
|
||||
_objTable!["track1"] = ctx.Track1;
|
||||
_objTable!["track2"] = ctx.Track2;
|
||||
_objTable!["track3"] = ctx.Track3;
|
||||
_objTable!["check0"] = ctx.Check0;
|
||||
_objTable!["check1"] = ctx.Check1;
|
||||
_objTable!["check2"] = ctx.Check2;
|
||||
_objTable!["check3"] = ctx.Check3;
|
||||
if (ctx.HasColor)
|
||||
script.Globals["color"] = ctx.ColorValue;
|
||||
_objTable!["time"] = ctx.Time;
|
||||
_objTable!["frame"] = ctx.Frame;
|
||||
_objTable!["totalframe"] = ctx.TotalFrame;
|
||||
@@ -451,6 +458,57 @@ namespace LuaScript
|
||||
});
|
||||
|
||||
obj["putpixeldata"] = DynValue.NewCallback((_, _) => DynValue.Void);
|
||||
|
||||
obj["rand"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
double frameDefault = _activeContext?.Frame ?? 0d;
|
||||
double a = args.Count > 0 ? args[0].CastToNumber() ?? 0d : 0d;
|
||||
double b = args.Count > 1 ? args[1].CastToNumber() ?? 0d : 0d;
|
||||
double seed = args.Count > 2 ? args[2].CastToNumber() ?? 0d : 0d;
|
||||
double frame = args.Count > 3 ? args[3].CastToNumber() ?? frameDefault : frameDefault;
|
||||
return DynValue.NewNumber(AviUtlRandom.Next(a, b, seed, frame));
|
||||
});
|
||||
|
||||
obj["load"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
if (_activeContext is null || args.Count < 4)
|
||||
return DynValue.Void;
|
||||
if (args[0].Type != DataType.String || args[0].String != "figure")
|
||||
return DynValue.Void;
|
||||
|
||||
string name = args[1].Type == DataType.String ? args[1].String : string.Empty;
|
||||
int color = (int)(args[2].CastToNumber() ?? 0d);
|
||||
double size = args[3].CastToNumber() ?? 0d;
|
||||
double line = args.Count > 4 ? args[4].CastToNumber() ?? 0d : 0d;
|
||||
double aspect = args.Count > 5 ? Math.Clamp(args[5].CastToNumber() ?? 0d, -1d, 1d) : 0d;
|
||||
|
||||
LoadFigure(name, color, size, line, aspect);
|
||||
return DynValue.Void;
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadFigure(string name, int color, double size, double line, double aspect)
|
||||
{
|
||||
int boundingSize = Math.Max(1, (int)Math.Round(size));
|
||||
double width = aspect >= 0d ? boundingSize * (1d - aspect) : boundingSize;
|
||||
double height = aspect <= 0d ? boundingSize * (1d + aspect) : boundingSize;
|
||||
int w = Math.Max(1, (int)Math.Round(width));
|
||||
int h = Math.Max(1, (int)Math.Round(height));
|
||||
|
||||
var buffer = FigureRenderer.Render(name, w, h, color, line);
|
||||
_activeContext!.ReplaceBuffer(buffer, w, h);
|
||||
|
||||
var obj = _objTable!;
|
||||
obj["w"] = w;
|
||||
obj["h"] = h;
|
||||
obj["hw"] = w / 2d;
|
||||
obj["hh"] = h / 2d;
|
||||
obj["cx"] = w / 2d;
|
||||
obj["cy"] = h / 2d;
|
||||
obj["cz"] = 0d;
|
||||
obj["diagonal"] = Math.Sqrt((double)w * w + (double)h * h);
|
||||
}
|
||||
|
||||
private static DynValue BuildObjectTable(Script script, SceneObjectInfo info)
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>خانة 3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -9,6 +9,13 @@ 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)
|
||||
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
|
||||
Check3,,チェック3,Check 3,复选框3,核取方塊3,체크3,Casilla 3,خانة 3,Centang 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)
|
||||
ToolBarImport,,インポート,Import,导入,導入,가져오기,Importar,استيراد,Impor
|
||||
ToolBarExport,,エクスポート,Export,导出,導出,내보내기,Exportar,تصدير,Ekspor
|
||||
ToolBarClear,,クリア,Clear,清除,清除,지우기,Limpiar,مسح,Hapus
|
||||
|
||||
|
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>Check 3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>Casilla 3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>Centang 3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>체크3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>チェック3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>复选框3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<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="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>
|
||||
<data name="Check3" xml:space="preserve"><value>核取方塊3</value></data>
|
||||
<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="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>
|
||||
|
||||
@@ -301,6 +301,38 @@
|
||||
لكن في هذا المكوِّن الإضافي تنعكس التغييرات عبر setpixel/set تلقائياً،
|
||||
لذا لا داعي لاستدعاء هذه الدالة.
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
تُعيد قيمة عشوائية صحيحة حتمية ضمن النطاق st ~ ed.
|
||||
* مع نفس seed و frame، تُعيد دائماً القيمة نفسها.
|
||||
* عند حذف seed يُعتبر 0، وعند حذف frame يُستخدم الإطار الحالي (obj.frame).
|
||||
* تُعيد القيمة نفسها على محرك MoonSharp وعلى زمن التشغيل LuaJIT.
|
||||
إذا لزمت قيمة عشوائية عشرية مستقلة عن المحرك، فاستخدم anim.rand.
|
||||
st : الحد الأدنى للنطاق (يُقتطع إلى عدد صحيح)
|
||||
ed : الحد الأعلى للنطاق (يُقتطع إلى عدد صحيح)
|
||||
seed : بذرة العشوائية (اختياري، الافتراضي 0)
|
||||
frame : الإطار المستخدم للتغيير (اختياري، الافتراضي obj.frame)
|
||||
النتيجة : عدد صحيح ضمن st ~ ed
|
||||
مثال: obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
○ obj.load(الهدف، ...)
|
||||
يستبدل مخزن الكائن بمحتوى مُولَّد. في هذا الإصدار يُدعم الهدف "figure" فقط.
|
||||
obj.load("figure", name, color, size [, line [, aspect]])
|
||||
يُولّد شكلاً ويستبدل مخزن الكائن به
|
||||
(يُعاد تحجيم الخرج ليطابق الشكل ويُتوسَّط).
|
||||
name : اسم الشكل. أحد 円 / 四角形 / 三角形 / 五角形 /
|
||||
六角形 / 星形 (وتُقبل الأسماء الإنجليزية circle, rect,
|
||||
triangle, pentagon, hexagon, star).
|
||||
color : لون التعبئة 0xRRGGBB.
|
||||
size : الحجم الأساسي بالبكسل.
|
||||
line : عرض الحد (اختياري). الحذف أو 0 يملأ الشكل،
|
||||
والقيمة المساوية للحجم أو الأكبر منه تملؤه أيضاً.
|
||||
aspect : التشويه -1.0 ~ 1.0 (اختياري). الموجب يقلّص العرض،
|
||||
والسالب يقلّص الارتفاع.
|
||||
مثال: obj.load("figure", "円", 0xff3366, 200)
|
||||
※ المُنفَّذ هو obj.load("figure", ...) فقط. الأهداف الأخرى
|
||||
(ملفات الصور و"text" و"tempbuffer" و"movie" وغيرها) لا تفعل شيئاً.
|
||||
※ تُنفَّذ نصوص الرسم على محرك MoonSharp.
|
||||
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -441,10 +473,53 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- التوافق الجزئي مع نصوص AviUtl -
|
||||
|
||||
تتيح طبقة توافق تشغيل الأجزاء الخاصة بالتحويل والشفافية والأرقام العشوائية من
|
||||
نصوص تأثير الحركة في AviUtl (عائلة *.anm) دون إعادة كتابة. عندما لا يحتوي النص
|
||||
على صياغة خاصة بـ AviUtl، لا تتدخل هذه الطبقة على الإطلاق (تبقى سلوكيات النصوص
|
||||
الحالية كما هي تماماً).
|
||||
|
||||
○ توجيهات ترويسة النص
|
||||
تُفسَّر إعلانات المعاملات المكتوبة على هيئة تعليقات، وتُعرَّف المتغيرات التي
|
||||
يشير إليها جسم النص قبل التنفيذ.
|
||||
--dialog:التسمية,local var=الافتراضي;...
|
||||
يوسّع جزء الإعلان لكل عنصر (مثل local var=الافتراضي) إلى بداية الجسم.
|
||||
في AviUtl تُحرَّر هذه القيم في مربع حوار، وهنا تُستخدم القيم الافتراضية.
|
||||
--color:0xRRGGBB
|
||||
يُعرّف المتغير color باللون المحدد.
|
||||
--check0:التسمية,الافتراضي
|
||||
يُعرّف obj.check0 (من 0 إلى 3) بالقيمة الافتراضية.
|
||||
--param:<عبارة Lua>
|
||||
يوسّع عبارة Lua المكتوبة إلى بداية الجسم.
|
||||
--track0: إلى --track3:
|
||||
تُقرأ قيم أشرطة التتبع عبر obj.track0 إلى obj.track3 كما في السابق.
|
||||
لا تنعكس التسمية والنطاق والقيمة الافتراضية في الترويسة على الواجهة.
|
||||
|
||||
○ أقسام متعددة باستخدام @
|
||||
عندما يُعرّف نص واحد عدة تأثيرات باستخدام @الاسم، يُنفَّذ القسم الأول فقط.
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
دالة أرقام عشوائية صحيحة حتمية متوافقة مع AviUtl. انظر "جدول obj - الدوال"
|
||||
للتفاصيل.
|
||||
|
||||
○ رسم الأشكال
|
||||
obj.load("figure", ...) يُولّد دائرة أو مربعاً أو مثلثاً أو خماسياً أو
|
||||
سداسياً أو نجمة، ويستبدل مخزن الكائن به. انظر "جدول obj - الدوال" للتفاصيل.
|
||||
|
||||
تتطلب الميزات التالية التكامل مع خط أنابيب الرسم، لذا فهي خارج نطاق هذه الطبقة.
|
||||
النصوص التي تستدعيها لن تعمل كما هو متوقع.
|
||||
× الرسم والتركيب (obj.draw / obj.drawpoly)، وأهداف obj.load غير "figure"
|
||||
(ملفات الصور و"text" و"movie" وغيرها)، وكذلك obj.setfont
|
||||
× تأثيرات المرشّحات وعمليات المخزن المؤقت
|
||||
(obj.effect / obj.copybuffer / obj.setoption وما شابه)
|
||||
× تحميل الوحدات عبر require، والوصول إلى الملفات مثل io
|
||||
|
||||
|
||||
- الميزات غير المدعومة / القيود -
|
||||
|
||||
× obj.effect()، obj.draw()، obj.drawpoly()، obj.load() وما شابه من AviUtl2 غير مدعومة.
|
||||
× obj.rand()، obj.rand1()، obj.setfont()، obj.mes() وما شابه من AviUtl2 غير مدعومة.
|
||||
× obj.effect()، obj.draw()، obj.drawpoly() وما شابه من AviUtl2 غير مدعومة (يُدعم obj.load("figure", ...) فقط؛ انظر "التوافق الجزئي مع نصوص AviUtl").
|
||||
× obj.rand1()، obj.setfont()، obj.mes() وما شابه من AviUtl2 غير مدعومة.
|
||||
× obj.setoption()، obj.getoption()، obj.getvalue()، obj.setanchor() وما شابه من AviUtl2 غير مدعومة.
|
||||
× الدوال مثل scene.set() و scene.get() في جدول scene الخاص بـ AviUtl2 غير مدعومة.
|
||||
(يمكن قراءة scene.width و scene.height فقط)
|
||||
@@ -453,5 +528,7 @@
|
||||
لكن دعم الرسم ثلاثي الأبعاد محدود.
|
||||
× إذا تجاوز النص البرمجي مهلة الانتهاء (5 ثوانٍ)، يُنهى التنفيذ قسراً.
|
||||
يجب الانتباه في التطبيق لتجنب الحلقات اللانهائية.
|
||||
× توجيهات الترويسة من AviUtl2 مثل --track@ و --check@ غير مدعومة.
|
||||
يمكن استخدام Track0 ~ Track3 فقط كمعاملات.
|
||||
× توجيهات الترويسة من AviUtl2 مدعومة جزئياً فقط. تُفسَّر القيم الافتراضية لـ
|
||||
--dialog / --color / --check / --param (انظر "التوافق الجزئي مع نصوص AviUtl")،
|
||||
لكن التسمية والنطاق والقيمة الافتراضية لـ --track@ لا تنعكس على الواجهة،
|
||||
وتُستخدم القيم عبر Track0 ~ Track3.
|
||||
@@ -307,6 +307,40 @@
|
||||
but in this plugin changes via setpixel/set are automatically applied,
|
||||
so calling this function is unnecessary.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
Returns a deterministic integer random value within the range st ~ ed.
|
||||
* With the same seed and frame, it always returns the same value.
|
||||
* When seed is omitted it is treated as 0; when frame is omitted the
|
||||
current frame (obj.frame) is used.
|
||||
* Returns the same value on both the MoonSharp engine and the LuaJIT
|
||||
runtime. For an engine-independent floating-point random value, use anim.rand.
|
||||
st : Lower bound of the range (truncated to an integer)
|
||||
ed : Upper bound of the range (truncated to an integer)
|
||||
seed : Random seed (optional, default 0)
|
||||
frame : Frame used for variation (optional, default obj.frame)
|
||||
Returns : An integer within st ~ ed
|
||||
Example: obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
o obj.load(target, ...)
|
||||
Replaces the object buffer with generated content.
|
||||
Only the "figure" target is supported in this version.
|
||||
obj.load("figure", name, color, size [, line [, aspect]])
|
||||
Generates a shape and replaces the object buffer with it
|
||||
(the output is resized to the shape and centered).
|
||||
name : Shape name. One of 円 / 四角形 / 三角形 / 五角形 /
|
||||
六角形 / 星形 (English aliases circle, rect,
|
||||
triangle, pentagon, hexagon, star are also accepted).
|
||||
color : Fill color 0xRRGGBB.
|
||||
size : Bounding size in pixels.
|
||||
line : Outline width (optional). Omitted or 0 fills the
|
||||
shape; a value at or above the size also fills it.
|
||||
aspect : Distortion -1.0 ~ 1.0 (optional). Positive shrinks
|
||||
the width, negative shrinks the height.
|
||||
Example: obj.load("figure", "円", 0xff3366, 200)
|
||||
* Only obj.load("figure", ...) is implemented. Other targets
|
||||
(image files, "text", "tempbuffer", "movie", etc.) do nothing.
|
||||
* Drawing scripts run on the MoonSharp engine.
|
||||
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -447,10 +481,58 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- AviUtl Script Compatibility (Partial) -
|
||||
|
||||
A compatibility layer lets the transform, opacity and random portions of
|
||||
AviUtl animation effect scripts (the *.anm family) run without rewriting.
|
||||
When a script contains no AviUtl-specific notation, this layer does not
|
||||
intervene at all, and existing scripts behave exactly as before.
|
||||
|
||||
o Script header directives
|
||||
Parameter declarations written as comments are interpreted, and the
|
||||
variables that the script body references are defined before execution.
|
||||
--dialog:label,local var=default;...
|
||||
Expands the declaration part of each item
|
||||
(such as local var=default) to the top of the body.
|
||||
In AviUtl these are edited in a dialog; here the default
|
||||
values are used.
|
||||
--color:0xRRGGBB
|
||||
Defines the variable color with the specified color.
|
||||
--check0:label,default
|
||||
Defines obj.check0 (0 to 3) with the default value.
|
||||
--param:<Lua statement>
|
||||
Expands the written Lua statement to the top of the body.
|
||||
--track0: to --track3:
|
||||
Trackbar values are referenced via obj.track0 to obj.track3
|
||||
as before. The label, range and default written in the header
|
||||
are not reflected in the UI.
|
||||
|
||||
o Multiple sections with @
|
||||
When a single script defines multiple effects with @name, only the
|
||||
first section is executed.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
A deterministic integer random function compatible with AviUtl.
|
||||
See "obj Table - Functions" for details.
|
||||
|
||||
o Figure drawing
|
||||
obj.load("figure", ...) generates a basic shape (circle, rectangle,
|
||||
triangle, pentagon, hexagon, star) and replaces the object buffer
|
||||
with it. See "obj Table - Functions" for details.
|
||||
|
||||
The following require integration with the rendering pipeline and are out of
|
||||
scope for this layer. Scripts that call them will not behave as intended.
|
||||
x Drawing and compositing (obj.draw / obj.drawpoly), obj.load targets
|
||||
other than "figure" (image files, "text", "movie", etc.) and obj.setfont
|
||||
x Filter effects and buffer operations
|
||||
(obj.effect / obj.copybuffer / obj.setoption, etc.)
|
||||
x Module loading via require, and file access such as io
|
||||
|
||||
|
||||
- Unsupported Features / Limitations -
|
||||
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), obj.load(), etc. from AviUtl2 are not supported.
|
||||
x obj.rand(), obj.rand1(), obj.setfont(), obj.mes(), etc. from AviUtl2 are not supported.
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), etc. from AviUtl2 are not supported (only obj.load("figure", ...) is supported; see "AviUtl Script Compatibility (Partial)").
|
||||
x obj.rand1(), obj.setfont(), obj.mes(), etc. from AviUtl2 are not supported.
|
||||
x obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor(), etc. from AviUtl2 are not supported.
|
||||
x Functions such as scene.set() and scene.get() in the AviUtl2 scene table are not supported.
|
||||
(Only scene.width and scene.height can be read)
|
||||
@@ -459,5 +541,7 @@
|
||||
but 3D rendering support is limited.
|
||||
x If the script timeout (5 seconds) is exceeded, execution is forcibly terminated.
|
||||
Care must be taken in implementation to prevent infinite loops.
|
||||
x AviUtl2 header directives such as --track@ and --check@ are not supported.
|
||||
Only Track0 ~ Track3 can be used as parameters.
|
||||
x AviUtl2 header directives are only partially supported. The default values of
|
||||
--dialog / --color / --check / --param are interpreted (see "AviUtl Script
|
||||
Compatibility (Partial)"), but the label, range and default of --track@ are
|
||||
not reflected in the UI; values are used via Track0 ~ Track3.
|
||||
@@ -305,6 +305,40 @@
|
||||
pero en este plugin los cambios mediante setpixel/set se aplican automáticamente,
|
||||
por lo que no es necesario llamar a esta función.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
Devuelve un valor aleatorio entero determinista dentro del rango st ~ ed.
|
||||
* Con el mismo seed y frame, siempre devuelve el mismo valor.
|
||||
* Si se omite seed se trata como 0; si se omite frame se usa el
|
||||
fotograma actual (obj.frame).
|
||||
* Devuelve el mismo valor en el motor MoonSharp y en el runtime LuaJIT.
|
||||
Para un valor aleatorio decimal independiente del motor, use anim.rand.
|
||||
st : Límite inferior del rango (truncado a entero)
|
||||
ed : Límite superior del rango (truncado a entero)
|
||||
seed : Semilla aleatoria (opcional, predeterminado 0)
|
||||
frame : Fotograma usado para la variación (opcional, predeterminado obj.frame)
|
||||
Devuelve: Un entero dentro de st ~ ed
|
||||
Ejemplo: obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
o obj.load(target, ...)
|
||||
Reemplaza el búfer del objeto con contenido generado.
|
||||
En esta versión solo se admite el target "figure".
|
||||
obj.load("figure", name, color, size [, line [, aspect]])
|
||||
Genera una forma y reemplaza el búfer del objeto con ella
|
||||
(la salida se redimensiona a la forma y se centra).
|
||||
name : Nombre de la forma. Uno de 円 / 四角形 / 三角形 /
|
||||
五角形 / 六角形 / 星形 (también se aceptan los alias
|
||||
en inglés circle, rect, triangle, pentagon, hexagon, star).
|
||||
color : Color de relleno 0xRRGGBB.
|
||||
size : Tamaño base en píxeles.
|
||||
line : Grosor del contorno (opcional). Omitido o 0 rellena la
|
||||
forma; un valor igual o mayor que el tamaño también la rellena.
|
||||
aspect : Distorsión -1.0 ~ 1.0 (opcional). Positivo reduce el
|
||||
ancho, negativo reduce el alto.
|
||||
Ejemplo: obj.load("figure", "円", 0xff3366, 200)
|
||||
* Solo se implementa obj.load("figure", ...). Otros targets
|
||||
(archivos de imagen, "text", "tempbuffer", "movie", etc.) no hacen nada.
|
||||
* Los scripts de dibujo se ejecutan en el motor MoonSharp.
|
||||
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -445,10 +479,61 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- Compatibilidad parcial con scripts de AviUtl -
|
||||
|
||||
Una capa de compatibilidad permite ejecutar, sin reescritura, las partes de
|
||||
los scripts de efecto de animación de AviUtl (la familia *.anm) relativas a
|
||||
transformación, opacidad y números aleatorios. Cuando un script no contiene
|
||||
notación específica de AviUtl, esta capa no interviene en absoluto (los
|
||||
scripts existentes se comportan exactamente igual que antes).
|
||||
|
||||
o Directivas de encabezado del script
|
||||
Las declaraciones de parámetros escritas como comentarios se
|
||||
interpretan, y las variables que el cuerpo del script referencia se
|
||||
definen antes de la ejecución.
|
||||
--dialog:etiqueta,local var=predeterminado;...
|
||||
Expande la parte de declaración de cada elemento
|
||||
(como local var=predeterminado) al inicio del cuerpo.
|
||||
En AviUtl se editan en un cuadro de diálogo; aquí se usan
|
||||
los valores predeterminados.
|
||||
--color:0xRRGGBB
|
||||
Define la variable color con el color especificado.
|
||||
--check0:etiqueta,predeterminado
|
||||
Define obj.check0 (0 a 3) con el valor predeterminado.
|
||||
--param:<sentencia Lua>
|
||||
Expande la sentencia Lua escrita al inicio del cuerpo.
|
||||
--track0: a --track3:
|
||||
Los valores de las barras de seguimiento se referencian
|
||||
mediante obj.track0 a obj.track3 como antes. La etiqueta, el
|
||||
rango y el valor predeterminado del encabezado no se reflejan en la UI.
|
||||
|
||||
o Múltiples secciones con @
|
||||
Cuando un único script define varios efectos con @nombre, solo se
|
||||
ejecuta la primera sección.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
Función de número aleatorio entero determinista compatible con AviUtl.
|
||||
Consulte "Tabla obj - Funciones" para más detalles.
|
||||
|
||||
o Dibujo de figuras
|
||||
obj.load("figure", ...) genera una forma básica (círculo, rectángulo,
|
||||
triángulo, pentágono, hexágono, estrella) y reemplaza el búfer del
|
||||
objeto con ella. Consulte "Tabla obj - Funciones" para más detalles.
|
||||
|
||||
Lo siguiente requiere integración con la canalización de renderizado y, por
|
||||
tanto, queda fuera del alcance de esta capa. Los scripts que lo llamen no se
|
||||
comportarán como se espera.
|
||||
x Dibujo y composición (obj.draw / obj.drawpoly), targets de obj.load
|
||||
distintos de "figure" (archivos de imagen, "text", "movie", etc.) y obj.setfont
|
||||
x Efectos de filtro y operaciones de búfer
|
||||
(obj.effect / obj.copybuffer / obj.setoption, etc.)
|
||||
x Carga de módulos mediante require y acceso a archivos como io
|
||||
|
||||
|
||||
- Funciones no admitidas / Limitaciones -
|
||||
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), obj.load(), etc. de AviUtl2 no son compatibles.
|
||||
x obj.rand(), obj.rand1(), obj.setfont(), obj.mes(), etc. de AviUtl2 no son compatibles.
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), etc. de AviUtl2 no son compatibles (solo se admite obj.load("figure", ...); consulte "Compatibilidad parcial con scripts de AviUtl").
|
||||
x obj.rand1(), obj.setfont(), obj.mes(), etc. de AviUtl2 no son compatibles.
|
||||
x obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor(), etc. de AviUtl2 no son compatibles.
|
||||
x Las funciones como scene.set() y scene.get() de la tabla scene de AviUtl2 no son compatibles.
|
||||
(Solo se pueden leer scene.width y scene.height)
|
||||
@@ -457,5 +542,7 @@
|
||||
pero el soporte de renderizado 3D es limitado.
|
||||
x Si se supera el tiempo de espera del script (5 segundos), la ejecución se termina forzosamente.
|
||||
Se debe tener cuidado en la implementación para evitar bucles infinitos.
|
||||
x Las directivas de encabezado de AviUtl2 como --track@ y --check@ no son compatibles.
|
||||
Solo Track0 ~ Track3 pueden usarse como parámetros.
|
||||
x Las directivas de encabezado de AviUtl2 solo son compatibles parcialmente. Los valores
|
||||
predeterminados de --dialog / --color / --check / --param se interpretan (consulte
|
||||
"Compatibilidad parcial con scripts de AviUtl"), pero la etiqueta, el rango y el valor
|
||||
predeterminado de --track@ no se reflejan en la UI; los valores se usan vía Track0 ~ Track3.
|
||||
@@ -303,6 +303,40 @@
|
||||
tetapi dalam plugin ini perubahan melalui setpixel/set diterapkan secara otomatis,
|
||||
sehingga tidak perlu memanggil fungsi ini.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
Mengembalikan nilai acak bilangan bulat deterministik dalam rentang st ~ ed.
|
||||
* Dengan seed dan frame yang sama, selalu mengembalikan nilai yang sama.
|
||||
* Jika seed dihilangkan dianggap 0; jika frame dihilangkan digunakan
|
||||
frame saat ini (obj.frame).
|
||||
* Mengembalikan nilai yang sama pada mesin MoonSharp maupun runtime LuaJIT.
|
||||
Untuk nilai acak desimal yang independen dari mesin, gunakan anim.rand.
|
||||
st : Batas bawah rentang (dipotong menjadi bilangan bulat)
|
||||
ed : Batas atas rentang (dipotong menjadi bilangan bulat)
|
||||
seed : Seed acak (opsional, default 0)
|
||||
frame : Frame yang digunakan untuk variasi (opsional, default obj.frame)
|
||||
Hasil : Bilangan bulat dalam st ~ ed
|
||||
Contoh: obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
o obj.load(target, ...)
|
||||
Mengganti buffer objek dengan konten yang dihasilkan.
|
||||
Pada versi ini hanya target "figure" yang didukung.
|
||||
obj.load("figure", name, color, size [, line [, aspect]])
|
||||
Menghasilkan sebuah bentuk dan mengganti buffer objek dengannya
|
||||
(output diubah ukurannya sesuai bentuk dan dipusatkan).
|
||||
name : Nama bentuk. Salah satu dari 円 / 四角形 / 三角形 /
|
||||
五角形 / 六角形 / 星形 (alias Inggris circle, rect,
|
||||
triangle, pentagon, hexagon, star juga diterima).
|
||||
color : Warna isi 0xRRGGBB.
|
||||
size : Ukuran dasar dalam piksel.
|
||||
line : Lebar garis tepi (opsional). Dihilangkan atau 0 mengisi
|
||||
bentuk; nilai sama atau lebih besar dari ukuran juga mengisinya.
|
||||
aspect : Distorsi -1.0 ~ 1.0 (opsional). Positif mengecilkan
|
||||
lebar, negatif mengecilkan tinggi.
|
||||
Contoh: obj.load("figure", "円", 0xff3366, 200)
|
||||
* Hanya obj.load("figure", ...) yang diimplementasikan. Target lain
|
||||
(berkas gambar, "text", "tempbuffer", "movie", dll.) tidak melakukan apa pun.
|
||||
* Skrip penggambaran dijalankan pada mesin MoonSharp.
|
||||
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
@@ -443,10 +477,60 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- Kompatibilitas Parsial Skrip AviUtl -
|
||||
|
||||
Lapisan kompatibilitas memungkinkan bagian transformasi, opasitas, dan
|
||||
bilangan acak dari skrip efek animasi AviUtl (keluarga *.anm) dijalankan
|
||||
tanpa penulisan ulang. Ketika sebuah skrip tidak mengandung notasi khusus
|
||||
AviUtl, lapisan ini tidak ikut campur sama sekali (skrip yang ada berperilaku
|
||||
persis seperti sebelumnya).
|
||||
|
||||
o Direktif header skrip
|
||||
Deklarasi parameter yang ditulis sebagai komentar diinterpretasikan,
|
||||
dan variabel yang dirujuk oleh badan skrip didefinisikan sebelum eksekusi.
|
||||
--dialog:label,local var=default;...
|
||||
Memperluas bagian deklarasi setiap item
|
||||
(seperti local var=default) ke awal badan skrip.
|
||||
Di AviUtl nilai ini diedit dalam dialog; di sini digunakan
|
||||
nilai default.
|
||||
--color:0xRRGGBB
|
||||
Mendefinisikan variabel color dengan warna yang ditentukan.
|
||||
--check0:label,default
|
||||
Mendefinisikan obj.check0 (0 sampai 3) dengan nilai default.
|
||||
--param:<pernyataan Lua>
|
||||
Memperluas pernyataan Lua yang ditulis ke awal badan skrip.
|
||||
--track0: sampai --track3:
|
||||
Nilai trackbar dirujuk melalui obj.track0 sampai obj.track3
|
||||
seperti sebelumnya. Label, rentang, dan default pada header
|
||||
tidak tercermin di UI.
|
||||
|
||||
o Beberapa bagian dengan @
|
||||
Ketika satu skrip mendefinisikan beberapa efek dengan @nama, hanya
|
||||
bagian pertama yang dijalankan.
|
||||
|
||||
o obj.rand(st, ed [, seed [, frame]])
|
||||
Fungsi bilangan acak bulat deterministik yang kompatibel dengan AviUtl.
|
||||
Lihat "Tabel obj - Fungsi" untuk detailnya.
|
||||
|
||||
o Penggambaran figur
|
||||
obj.load("figure", ...) menghasilkan bentuk dasar (lingkaran, persegi,
|
||||
segitiga, segilima, segienam, bintang) dan mengganti buffer objek
|
||||
dengannya. Lihat "Tabel obj - Fungsi" untuk detailnya.
|
||||
|
||||
Berikut ini memerlukan integrasi dengan pipeline render sehingga berada di
|
||||
luar cakupan lapisan ini. Skrip yang memanggilnya tidak akan berperilaku
|
||||
seperti yang diharapkan.
|
||||
x Penggambaran dan komposisi (obj.draw / obj.drawpoly), target obj.load
|
||||
selain "figure" (berkas gambar, "text", "movie", dll.) dan obj.setfont
|
||||
x Efek filter dan operasi buffer
|
||||
(obj.effect / obj.copybuffer / obj.setoption, dll.)
|
||||
x Pemuatan modul melalui require, dan akses file seperti io
|
||||
|
||||
|
||||
- Fitur yang Tidak Didukung / Batasan -
|
||||
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), obj.load(), dll. dari AviUtl2 tidak didukung.
|
||||
x obj.rand(), obj.rand1(), obj.setfont(), obj.mes(), dll. dari AviUtl2 tidak didukung.
|
||||
x obj.effect(), obj.draw(), obj.drawpoly(), dll. dari AviUtl2 tidak didukung (hanya obj.load("figure", ...) yang didukung; lihat "Kompatibilitas Parsial Skrip AviUtl").
|
||||
x obj.rand1(), obj.setfont(), obj.mes(), dll. dari AviUtl2 tidak didukung.
|
||||
x obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor(), dll. dari AviUtl2 tidak didukung.
|
||||
x Fungsi seperti scene.set() dan scene.get() dalam tabel scene AviUtl2 tidak didukung.
|
||||
(Hanya scene.width dan scene.height yang dapat dibaca)
|
||||
@@ -455,5 +539,7 @@
|
||||
tetapi dukungan render 3D terbatas.
|
||||
x Jika batas waktu skrip (5 detik) terlampaui, eksekusi dihentikan paksa.
|
||||
Perhatian harus diberikan dalam implementasi untuk mencegah loop tak terbatas.
|
||||
x Direktif header AviUtl2 seperti --track@ dan --check@ tidak didukung.
|
||||
Hanya Track0 ~ Track3 yang dapat digunakan sebagai parameter.
|
||||
x Direktif header AviUtl2 hanya didukung sebagian. Nilai default dari
|
||||
--dialog / --color / --check / --param diinterpretasikan (lihat "Kompatibilitas
|
||||
Parsial Skrip AviUtl"), tetapi label, rentang, dan default dari --track@ tidak
|
||||
tercermin di UI; nilai digunakan melalui Track0 ~ Track3.
|
||||
@@ -303,6 +303,38 @@
|
||||
このプラグインでは setpixel/set による変更が自動的に反映されるため、
|
||||
本関数を呼び出す必要はありません。
|
||||
|
||||
○obj.rand(st, ed [, seed [, frame]])
|
||||
指定範囲 st ~ ed の整数を返す決定論的な乱数です。
|
||||
※ seed と frame が同じであれば常に同じ値を返します。
|
||||
※ seed 省略時は 0、frame 省略時は現在のフレーム(obj.frame)を使用します。
|
||||
※ 従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)で同じ値を返します。
|
||||
エンジンに依存しない小数の乱数が必要な場合は anim.rand を使用してください。
|
||||
st : 範囲の下限 (小数は切り捨てて整数化)
|
||||
ed : 範囲の上限 (小数は切り捨てて整数化)
|
||||
seed : 乱数シード (省略可, デフォルト 0)
|
||||
frame : 変化に用いるフレーム (省略可, デフォルト obj.frame)
|
||||
戻り値 : st ~ ed の整数
|
||||
例:obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
○obj.load(対象, ...)
|
||||
オブジェクトのバッファを生成した内容に置き換えます。
|
||||
本バージョンでは "figure"(図形)のみ対応します。
|
||||
obj.load("figure", 名前, 色, サイズ [, ライン [, アスペクト]])
|
||||
図形を生成してオブジェクトのバッファを置き換えます
|
||||
(出力は図形サイズに合わせて生成され、中心に配置されます)。
|
||||
名前 : 図形名。円 / 四角形 / 三角形 / 五角形 / 六角形 /
|
||||
星形 のいずれか(英語名 circle, rect, triangle,
|
||||
pentagon, hexagon, star も使用可)。
|
||||
色 : 塗り色 0xRRGGBB。
|
||||
サイズ : 図形の基準サイズ(ピクセル)。
|
||||
ライン : 輪郭の太さ(省略可)。省略または 0 で塗りつぶし。
|
||||
サイズ以上の値を指定した場合も塗りつぶしになります。
|
||||
アスペクト: 歪曲 -1.0 ~ 1.0(省略可)。正で横幅、負で縦幅が縮みます。
|
||||
例:obj.load("figure", "円", 0xff3366, 200)
|
||||
※ 実装されているのは obj.load("figure", ...) のみです。画像ファイルや
|
||||
"text"・"tempbuffer"・"movie" 等の対象は何も行いません。
|
||||
※ 描画系スクリプトは従来エンジン(MoonSharp)で実行されます。
|
||||
|
||||
|
||||
|
||||
- ymm4 テーブル -
|
||||
@@ -443,10 +475,56 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- AviUtl スクリプトの部分互換 -
|
||||
|
||||
AviUtl のアニメーション効果スクリプト(*.anm 系)のうち、座標・拡縮・回転・
|
||||
不透明度の変形と乱数を用いる範囲を、追加の記述変更なしで実行できる互換層です。
|
||||
スクリプトに AviUtl 固有の記法が含まれない場合、この互換層は一切介入しません
|
||||
(従来のスクリプトの挙動は変わりません)。
|
||||
|
||||
○スクリプトヘッダの解釈
|
||||
コメント形式のパラメータ宣言を解釈し、スクリプト本体が参照する変数を
|
||||
実行前に定義します。
|
||||
--dialog:項目名,local 変数=既定値;…
|
||||
各項目の宣言部(local 変数=既定値 など)を本体の先頭へ展開します。
|
||||
AviUtl では対話ダイアログで編集する値ですが、ここでは既定値で
|
||||
動作します。
|
||||
--color:0xRRGGBB
|
||||
変数 color を指定色で定義します。
|
||||
--check0:項目名,既定値
|
||||
obj.check0 (0~3) を既定値で定義します。
|
||||
--param:任意のLua文
|
||||
記述した Lua 文をそのまま本体の先頭へ展開します。
|
||||
--track0: ~ --track3:
|
||||
トラックバーの値は従来どおり obj.track0 ~ obj.track3 から
|
||||
参照します。ヘッダーのラベル・範囲・既定値は UI へ反映しません。
|
||||
|
||||
○@ による複数セクション
|
||||
1 つのスクリプトに @名前 で複数の効果が定義されている場合、先頭の
|
||||
セクションのみを実行します。
|
||||
|
||||
○obj.rand(st, ed [, seed [, frame]])
|
||||
AviUtl 互換の決定論的な整数乱数です。詳細は「obj テーブル - 関数」を
|
||||
参照してください。
|
||||
|
||||
○図形描画
|
||||
obj.load("figure", ...) で円・四角形・三角形・五角形・六角形・星形を
|
||||
生成し、オブジェクトのバッファを置き換えます。詳細は「obj テーブル -
|
||||
関数」を参照してください。
|
||||
|
||||
次の機能は本体の描画パイプラインへの統合を要するため、この互換層では対象外です。
|
||||
これらを呼び出すスクリプトは意図どおりには動作しません。
|
||||
×描画・合成(obj.draw / obj.drawpoly)、obj.load の "figure" 以外の対象
|
||||
(画像ファイル・"text"・"movie" 等)、および obj.setfont
|
||||
×フィルタ効果やバッファ操作
|
||||
(obj.effect / obj.copybuffer / obj.setoption など)
|
||||
×require によるモジュール読み込み、io などのファイルアクセス
|
||||
|
||||
|
||||
- 非対応・制限事項 -
|
||||
|
||||
×AviUtl2 の obj.effect(), obj.draw(), obj.drawpoly(), obj.load() 等には対応していません。
|
||||
×AviUtl2 の obj.rand(), obj.rand1(), obj.setfont(), obj.mes() 等には対応していません。
|
||||
×AviUtl2 の obj.effect(), obj.draw(), obj.drawpoly() 等には対応していません(obj.load は "figure" のみ対応。「AviUtl スクリプトの部分互換」を参照)。
|
||||
×AviUtl2 の obj.rand1(), obj.setfont(), obj.mes() 等には対応していません。
|
||||
×AviUtl2 の obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor() 等には対応していません。
|
||||
×AviUtl2 の scene テーブルの scene.set(), scene.get() 等の関数には対応していません。
|
||||
(scene.width と scene.height の読み取りのみ対応)
|
||||
@@ -455,5 +533,7 @@
|
||||
3D 描画のサポートは限定的です。
|
||||
×スクリプトのタイムアウト(5秒)を超えた場合、実行は強制終了されます。
|
||||
無限ループが発生しないよう実装上の注意が必要です。
|
||||
×AviUtl2 の --track@, --check@ 等のヘッダーディレクティブには対応していません。
|
||||
パラメータは Track0 ~ Track3 のみ使用できます。
|
||||
×AviUtl2 のヘッダーディレクティブは部分的にのみ対応します。
|
||||
--dialog / --color / --check / --param の既定値は解釈されますが
|
||||
(「AviUtl スクリプトの部分互換」を参照)、--track@ のラベル・範囲・
|
||||
既定値は UI へ反映されず、値は Track0 ~ Track3 を使用します。
|
||||
@@ -299,6 +299,38 @@
|
||||
이 플러그인에서는 setpixel/set에 의한 변경이 자동으로 반영되므로,
|
||||
이 함수를 호출할 필요가 없습니다.
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
지정 범위 st ~ ed의 정수를 반환하는 결정론적 난수입니다.
|
||||
※ seed와 frame이 같으면 항상 같은 값을 반환합니다.
|
||||
※ seed 생략 시 0으로, frame 생략 시 현재 프레임(obj.frame)을 사용합니다.
|
||||
※ 기존 엔진(MoonSharp)과 고속 런타임(LuaJIT)에서 같은 값을 반환합니다.
|
||||
엔진에 의존하지 않는 소수 난수가 필요하면 anim.rand를 사용하세요.
|
||||
st : 범위 하한 (소수는 버림하여 정수화)
|
||||
ed : 범위 상한 (소수는 버림하여 정수화)
|
||||
seed : 난수 시드 (생략 가능, 기본값 0)
|
||||
frame : 변화에 사용하는 프레임 (생략 가능, 기본값 obj.frame)
|
||||
반환값 : st ~ ed의 정수
|
||||
예: obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
○ obj.load(대상, ...)
|
||||
오브젝트 버퍼를 생성한 내용으로 교체합니다.
|
||||
이 버전에서는 "figure"(도형)만 지원합니다.
|
||||
obj.load("figure", 이름, 색, 크기 [, 라인 [, 종횡비]])
|
||||
도형을 생성하여 오브젝트 버퍼를 교체합니다
|
||||
(출력은 도형 크기에 맞춰 생성되고 중심에 배치됩니다).
|
||||
이름 : 도형 이름. 円 / 四角形 / 三角形 / 五角形 / 六角形 /
|
||||
星形 중 하나(영어 circle, rect, triangle,
|
||||
pentagon, hexagon, star 도 사용 가능).
|
||||
색 : 채움 색 0xRRGGBB.
|
||||
크기 : 도형의 기준 크기(픽셀).
|
||||
라인 : 외곽선 두께(생략 가능). 생략 또는 0이면 채움.
|
||||
크기 이상의 값을 지정한 경우에도 채움이 됩니다.
|
||||
종횡비 : 왜곡 -1.0 ~ 1.0(생략 가능). 양수는 너비, 음수는 높이를 줄입니다.
|
||||
예: obj.load("figure", "円", 0xff3366, 200)
|
||||
※ 구현된 것은 obj.load("figure", ...) 뿐입니다. 이미지 파일,
|
||||
"text"・"tempbuffer"・"movie" 등의 대상은 아무것도 하지 않습니다.
|
||||
※ 그리기 계열 스크립트는 MoonSharp 엔진에서 실행됩니다.
|
||||
|
||||
|
||||
|
||||
- ymm4 테이블 -
|
||||
@@ -439,10 +471,56 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- AviUtl 스크립트 부분 호환 -
|
||||
|
||||
AviUtl 애니메이션 효과 스크립트(*.anm 계열) 중 좌표·확대축소·회전·
|
||||
불투명도의 변형과 난수를 사용하는 범위를, 추가 수정 없이 실행할 수 있는
|
||||
호환 계층입니다. 스크립트에 AviUtl 고유 표기가 포함되지 않은 경우 이
|
||||
호환 계층은 전혀 개입하지 않습니다(기존 스크립트의 동작은 변하지 않습니다).
|
||||
|
||||
○ 스크립트 헤더 디렉티브 해석
|
||||
주석 형식의 파라미터 선언을 해석하여, 스크립트 본문이 참조하는
|
||||
변수를 실행 전에 정의합니다.
|
||||
--dialog:항목명,local 변수=기본값;…
|
||||
각 항목의 선언부(local 변수=기본값 등)를 본문 앞에 펼칩니다.
|
||||
AviUtl에서는 대화 상자에서 편집하는 값이지만, 여기서는
|
||||
기본값으로 동작합니다.
|
||||
--color:0xRRGGBB
|
||||
변수 color를 지정한 색으로 정의합니다.
|
||||
--check0:항목명,기본값
|
||||
obj.check0 (0~3)을 기본값으로 정의합니다.
|
||||
--param:임의의 Lua 문
|
||||
작성한 Lua 문을 그대로 본문 앞에 펼칩니다.
|
||||
--track0: ~ --track3:
|
||||
트랙바 값은 기존과 같이 obj.track0 ~ obj.track3에서
|
||||
참조합니다. 헤더의 라벨·범위·기본값은 UI에 반영되지 않습니다.
|
||||
|
||||
○ @를 통한 복수 섹션
|
||||
하나의 스크립트에 @이름으로 여러 효과가 정의된 경우, 첫 번째
|
||||
섹션만 실행합니다.
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
AviUtl 호환의 결정론적 정수 난수입니다. 자세한 내용은
|
||||
"obj 테이블 - 함수"를 참조하세요.
|
||||
|
||||
○ 도형 그리기
|
||||
obj.load("figure", ...) 로 원·사각형·삼각형·오각형·육각형·별형을
|
||||
생성하여 오브젝트 버퍼를 교체합니다. 자세한 내용은
|
||||
"obj 테이블 - 함수"를 참조하세요.
|
||||
|
||||
다음 기능은 본체의 렌더링 파이프라인과의 통합이 필요하므로 이 호환
|
||||
계층의 범위 밖입니다. 이를 호출하는 스크립트는 의도대로 동작하지 않습니다.
|
||||
× 그리기·합성(obj.draw / obj.drawpoly), obj.load의 "figure" 이외 대상
|
||||
(이미지 파일·"text"・"movie" 등), 그리고 obj.setfont
|
||||
× 필터 효과 및 버퍼 조작
|
||||
(obj.effect / obj.copybuffer / obj.setoption 등)
|
||||
× require에 의한 모듈 로드 및 io 등의 파일 접근
|
||||
|
||||
|
||||
- 미지원·제한 사항 -
|
||||
|
||||
× AviUtl2의 obj.effect(), obj.draw(), obj.drawpoly(), obj.load() 등은 지원하지 않습니다.
|
||||
× AviUtl2의 obj.rand(), obj.rand1(), obj.setfont(), obj.mes() 등은 지원하지 않습니다.
|
||||
× AviUtl2의 obj.effect(), obj.draw(), obj.drawpoly() 등은 지원하지 않습니다(obj.load은 "figure"만 지원. "AviUtl 스크립트 부분 호환" 참조).
|
||||
× AviUtl2의 obj.rand1(), obj.setfont(), obj.mes() 등은 지원하지 않습니다.
|
||||
× AviUtl2의 obj.setoption(), obj.getoption(), obj.getvalue(), obj.setanchor() 등은 지원하지 않습니다.
|
||||
× AviUtl2의 scene 테이블의 scene.set(), scene.get() 등의 함수는 지원하지 않습니다.
|
||||
(scene.width와 scene.height의 읽기만 지원)
|
||||
@@ -451,5 +529,6 @@
|
||||
3D 렌더링 지원은 제한적입니다.
|
||||
× 스크립트 타임아웃(5초)을 초과하면 실행이 강제 종료됩니다.
|
||||
무한 루프가 발생하지 않도록 구현 시 주의가 필요합니다.
|
||||
× AviUtl2의 --track@, --check@ 등의 헤더 디렉티브는 지원하지 않습니다.
|
||||
파라미터는 Track0 ~ Track3만 사용할 수 있습니다.
|
||||
× AviUtl2의 헤더 디렉티브는 부분적으로만 지원합니다. --dialog / --color /
|
||||
--check / --param의 기본값은 해석되지만("AviUtl 스크립트 부분 호환" 참조),
|
||||
--track@의 라벨·범위·기본값은 UI에 반영되지 않으며 값은 Track0 ~ Track3을 사용합니다.
|
||||
@@ -297,6 +297,37 @@
|
||||
但本插件中 setpixel/set 的修改会自动反映,
|
||||
因此无需调用此函数。
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
返回指定范围 st ~ ed 内整数的确定性随机数。
|
||||
* seed 与 frame 相同时始终返回相同的值。
|
||||
* 省略 seed 时按 0 处理,省略 frame 时使用当前帧 (obj.frame)。
|
||||
* 在传统引擎 (MoonSharp) 与高速运行时 (LuaJIT) 上返回相同的值。
|
||||
若需要不依赖引擎的小数随机数,请使用 anim.rand。
|
||||
st : 范围下限(小数向下取整为整数)
|
||||
ed : 范围上限(小数向下取整为整数)
|
||||
seed : 随机种子(可省略,默认 0)
|
||||
frame : 用于变化的帧(可省略,默认 obj.frame)
|
||||
返回值 : st ~ ed 的整数
|
||||
示例:obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
○ obj.load(目标, ...)
|
||||
将对象缓冲区替换为生成的内容。本版本仅支持 "figure"(图形)。
|
||||
obj.load("figure", 名称, 颜色, 大小 [, 线宽 [, 纵横比]])
|
||||
生成图形并替换对象缓冲区
|
||||
(输出按图形大小生成并居中)。
|
||||
名称 : 图形名。円 / 四角形 / 三角形 / 五角形 / 六角形 /
|
||||
星形 之一(也可用英文 circle, rect, triangle,
|
||||
pentagon, hexagon, star)。
|
||||
颜色 : 填充色 0xRRGGBB。
|
||||
大小 : 图形基准大小(像素)。
|
||||
线宽 : 轮廓宽度(可省略)。省略或 0 为填充;
|
||||
指定大于等于大小的值时也为填充。
|
||||
纵横比 : 变形 -1.0 ~ 1.0(可省略)。正值缩小宽度,负值缩小高度。
|
||||
示例:obj.load("figure", "円", 0xff3366, 200)
|
||||
* 仅实现了 obj.load("figure", ...)。图像文件、"text"、"tempbuffer"、
|
||||
"movie" 等目标不执行任何操作。
|
||||
* 绘制类脚本在 MoonSharp 引擎上运行。
|
||||
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
@@ -437,10 +468,50 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- AviUtl 脚本的部分兼容 -
|
||||
|
||||
提供兼容层,使 AviUtl 动画效果脚本(*.anm 系列)中涉及坐标、缩放、旋转、
|
||||
不透明度的变形以及随机数的部分,无需额外修改即可运行。当脚本中不包含
|
||||
AviUtl 专有写法时,此兼容层完全不介入(传统脚本的行为不变)。
|
||||
|
||||
○ 脚本头部指令的解释
|
||||
解释注释形式的参数声明,在执行前定义脚本主体所引用的变量。
|
||||
--dialog:项目名,local 变量=默认值;…
|
||||
将各项目的声明部分(如 local 变量=默认值)展开到主体开头。
|
||||
在 AviUtl 中这些是通过对话框编辑的值,此处以默认值运行。
|
||||
--color:0xRRGGBB
|
||||
以指定颜色定义变量 color。
|
||||
--check0:项目名,默认值
|
||||
以默认值定义 obj.check0 (0~3)。
|
||||
--param:任意 Lua 语句
|
||||
将所写的 Lua 语句原样展开到主体开头。
|
||||
--track0: ~ --track3:
|
||||
轨道条的值仍通过 obj.track0 ~ obj.track3 引用。头部的标签、
|
||||
范围与默认值不会反映到 UI。
|
||||
|
||||
○ 通过 @ 的多区段
|
||||
当一个脚本以 @名称 定义了多个效果时,仅执行第一个区段。
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
与 AviUtl 兼容的确定性整数随机数。详情请参阅“obj 表 - 函数”。
|
||||
|
||||
○ 图形绘制
|
||||
obj.load("figure", ...) 生成圆、四角形、三角形、五角形、六角形、星形,
|
||||
并替换对象缓冲区。详情请参阅“obj 表 - 函数”。
|
||||
|
||||
以下功能需要与本体的绘制管线集成,因此不在此兼容层的范围内。
|
||||
调用它们的脚本不会按预期运行。
|
||||
× 绘制与合成(obj.draw / obj.drawpoly)、obj.load 的 "figure" 以外目标
|
||||
(图像文件、"text"、"movie" 等),以及 obj.setfont
|
||||
× 滤镜效果与缓冲区操作
|
||||
(obj.effect / obj.copybuffer / obj.setoption 等)
|
||||
× 通过 require 加载模块,以及 io 等文件访问
|
||||
|
||||
|
||||
- 不支持项目·限制事项 -
|
||||
|
||||
× 不支持 AviUtl2 的 obj.effect()、obj.draw()、obj.drawpoly()、obj.load() 等。
|
||||
× 不支持 AviUtl2 的 obj.rand()、obj.rand1()、obj.setfont()、obj.mes() 等。
|
||||
× 不支持 AviUtl2 的 obj.effect()、obj.draw()、obj.drawpoly() 等(obj.load 仅支持 "figure",参阅“AviUtl 脚本的部分兼容”)。
|
||||
× 不支持 AviUtl2 的 obj.rand1()、obj.setfont()、obj.mes() 等。
|
||||
× 不支持 AviUtl2 的 obj.setoption()、obj.getoption()、obj.getvalue()、obj.setanchor() 等。
|
||||
× 不支持 AviUtl2 scene 表中的 scene.set()、scene.get() 等函数。
|
||||
(仅支持读取 scene.width 和 scene.height)
|
||||
@@ -449,5 +520,6 @@
|
||||
但 3D 绘制支持有限。
|
||||
× 超过脚本超时时间(5 秒)时,执行将被强制终止。
|
||||
实现时需注意避免出现无限循环。
|
||||
× 不支持 AviUtl2 的 --track@、--check@ 等头部指令。
|
||||
参数仅可使用 Track0 ~ Track3。
|
||||
× AviUtl2 的头部指令仅部分支持。--dialog / --color / --check / --param 的
|
||||
默认值会被解释(参阅“AviUtl 脚本的部分兼容”),但 --track@ 的标签、范围
|
||||
与默认值不会反映到 UI,值通过 Track0 ~ Track3 使用。
|
||||
@@ -297,6 +297,37 @@
|
||||
但本外掛中 setpixel/set 的修改會自動反映,
|
||||
因此無需呼叫此函式。
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
回傳指定範圍 st ~ ed 內整數的確定性亂數。
|
||||
* seed 與 frame 相同時始終回傳相同的值。
|
||||
* 省略 seed 時以 0 處理,省略 frame 時使用目前影格 (obj.frame)。
|
||||
* 在傳統引擎 (MoonSharp) 與高速執行階段 (LuaJIT) 上回傳相同的值。
|
||||
若需要不依賴引擎的小數亂數,請使用 anim.rand。
|
||||
st : 範圍下限(小數無條件捨去為整數)
|
||||
ed : 範圍上限(小數無條件捨去為整數)
|
||||
seed : 亂數種子(可省略,預設 0)
|
||||
frame : 用於變化的影格(可省略,預設 obj.frame)
|
||||
回傳值 : st ~ ed 的整數
|
||||
範例:obj.ox = obj.ox + obj.rand(-10, 10, 1, obj.frame)
|
||||
|
||||
○ obj.load(目標, ...)
|
||||
將物件緩衝區替換為產生的內容。本版本僅支援 "figure"(圖形)。
|
||||
obj.load("figure", 名稱, 顏色, 大小 [, 線寬 [, 長寬比]])
|
||||
產生圖形並替換物件緩衝區
|
||||
(輸出依圖形大小產生並置中)。
|
||||
名稱 : 圖形名。円 / 四角形 / 三角形 / 五角形 / 六角形 /
|
||||
星形 之一(亦可用英文 circle, rect, triangle,
|
||||
pentagon, hexagon, star)。
|
||||
顏色 : 填滿色 0xRRGGBB。
|
||||
大小 : 圖形基準大小(像素)。
|
||||
線寬 : 輪廓寬度(可省略)。省略或 0 為填滿;
|
||||
指定大於等於大小的值時亦為填滿。
|
||||
長寬比 : 變形 -1.0 ~ 1.0(可省略)。正值縮小寬度,負值縮小高度。
|
||||
範例:obj.load("figure", "円", 0xff3366, 200)
|
||||
* 僅實作了 obj.load("figure", ...)。影像檔、"text"、"tempbuffer"、
|
||||
"movie" 等目標不執行任何動作。
|
||||
* 繪製類腳本在 MoonSharp 引擎上執行。
|
||||
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
@@ -437,10 +468,50 @@
|
||||
obj.zoom = obj.zoom * (1 + obj.track0 / 100)
|
||||
|
||||
|
||||
- AviUtl 腳本的部分相容 -
|
||||
|
||||
提供相容層,使 AviUtl 動畫效果腳本(*.anm 系列)中涉及座標、縮放、旋轉、
|
||||
不透明度的變形以及亂數的部分,無需額外修改即可執行。當腳本中不包含
|
||||
AviUtl 專有寫法時,此相容層完全不介入(傳統腳本的行為不變)。
|
||||
|
||||
○ 腳本標頭指令的解釋
|
||||
解釋註解形式的參數宣告,在執行前定義腳本主體所參考的變數。
|
||||
--dialog:項目名,local 變數=預設值;…
|
||||
將各項目的宣告部分(如 local 變數=預設值)展開至主體開頭。
|
||||
在 AviUtl 中這些是透過對話框編輯的值,此處以預設值執行。
|
||||
--color:0xRRGGBB
|
||||
以指定顏色定義變數 color。
|
||||
--check0:項目名,預設值
|
||||
以預設值定義 obj.check0 (0~3)。
|
||||
--param:任意 Lua 陳述式
|
||||
將所寫的 Lua 陳述式原樣展開至主體開頭。
|
||||
--track0: ~ --track3:
|
||||
軌道列的值仍透過 obj.track0 ~ obj.track3 參考。標頭的標籤、
|
||||
範圍與預設值不會反映至 UI。
|
||||
|
||||
○ 透過 @ 的多區段
|
||||
當一個腳本以 @名稱 定義了多個效果時,僅執行第一個區段。
|
||||
|
||||
○ obj.rand(st, ed [, seed [, frame]])
|
||||
與 AviUtl 相容的確定性整數亂數。詳情請參閱「obj 表 - 函式」。
|
||||
|
||||
○ 圖形繪製
|
||||
obj.load("figure", ...) 產生圓、四角形、三角形、五角形、六角形、星形,
|
||||
並替換物件緩衝區。詳情請參閱「obj 表 - 函式」。
|
||||
|
||||
以下功能需要與本體的繪製管線整合,因此不在此相容層的範圍內。
|
||||
呼叫它們的腳本不會如預期運作。
|
||||
× 繪製與合成(obj.draw / obj.drawpoly)、obj.load 的 "figure" 以外目標
|
||||
(影像檔、"text"、"movie" 等),以及 obj.setfont
|
||||
× 濾鏡效果與緩衝區操作
|
||||
(obj.effect / obj.copybuffer / obj.setoption 等)
|
||||
× 透過 require 載入模組,以及 io 等檔案存取
|
||||
|
||||
|
||||
- 不支援項目·限制事項 -
|
||||
|
||||
× 不支援 AviUtl2 的 obj.effect()、obj.draw()、obj.drawpoly()、obj.load() 等。
|
||||
× 不支援 AviUtl2 的 obj.rand()、obj.rand1()、obj.setfont()、obj.mes() 等。
|
||||
× 不支援 AviUtl2 的 obj.effect()、obj.draw()、obj.drawpoly() 等(obj.load 僅支援 "figure",參閱「AviUtl 腳本的部分相容」)。
|
||||
× 不支援 AviUtl2 的 obj.rand1()、obj.setfont()、obj.mes() 等。
|
||||
× 不支援 AviUtl2 的 obj.setoption()、obj.getoption()、obj.getvalue()、obj.setanchor() 等。
|
||||
× 不支援 AviUtl2 scene 表中的 scene.set()、scene.get() 等函式。
|
||||
(僅支援讀取 scene.width 和 scene.height)
|
||||
@@ -449,5 +520,6 @@
|
||||
但 3D 繪製支援有限。
|
||||
× 超過腳本逾時時間(5 秒)時,執行將被強制終止。
|
||||
實作時需注意避免出現無限迴圈。
|
||||
× 不支援 AviUtl2 的 --track@、--check@ 等標頭指令。
|
||||
參數僅可使用 Track0 ~ Track3。
|
||||
× AviUtl2 的標頭指令僅部分支援。--dialog / --color / --check / --param 的
|
||||
預設值會被解釋(參閱「AviUtl 腳本的部分相容」),但 --track@ 的標籤、範圍
|
||||
與預設值不會反映至 UI,值透過 Track0 ~ Track3 使用。
|
||||
@@ -29,6 +29,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
- [6. トラックバー(Track0〜Track3)](#6-トラックバーtrack0track3)
|
||||
- [7. スクリプトエディタの支援機能](#7-スクリプトエディタの支援機能)
|
||||
- [8. インポート・エクスポート・クリア](#8-インポートエクスポートクリア)
|
||||
- [9. AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)
|
||||
5. [実行モデル](#実行モデル)
|
||||
- [実行エンジンの自動振り分け](#実行エンジンの自動振り分け)
|
||||
- [実行スレッドとタイムアウト](#実行スレッドとタイムアウト)
|
||||
@@ -47,7 +48,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
|
||||
内部的には MoonSharp(Lua 5.2 互換のスクリプトエンジン)を組み込んでおり、ユーザーが記述した Lua スクリプトをフレームごとに実行します。スクリプト内で `obj.x` や `obj.alpha` といったグローバル変数を書き換えると、その値がオブジェクトの座標・拡縮・回転・不透明度として描画に反映されます。
|
||||
|
||||
このエフェクトは AviUtl2 のスクリプト仕様とは異なる独自実装であり、AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
このエフェクトは独自のスクリプト実行系を基盤としつつ、AviUtl のアニメーション効果スクリプト(`.anm` 系)の一部に対する互換層を備えています(詳細は[AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
|
||||
---
|
||||
|
||||
@@ -187,6 +188,29 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
- **インポート**: `.lua` ファイルを選択して読み込み、選択中のすべてのアイテムのスクリプトを置き換えます。
|
||||
- **エクスポート**: 現在のスクリプトを `.lua` ファイルとして保存します。複数のアイテムを選択している場合でも、書き出されるのは先頭の 1 件のスクリプトのみです。
|
||||
- **クリア**: 確認ダイアログの表示後、選択中のすべてのアイテムのスクリプトをデフォルトスクリプト(`obj.alpha = math.min(time * 255, 255)`)に戻します。
|
||||
|
||||
### 9. AviUtl スクリプトの部分互換
|
||||
|
||||
AviUtl のアニメーション効果スクリプト(`.anm` 系)のうち、座標・拡縮・回転・不透明度の変形、乱数、および図形描画について、追加の記述変更なしに実行できる互換層を備えています。スクリプトに AviUtl 固有の記法が含まれない場合、この互換層は一切介入しません(従来のスクリプトの挙動は変わりません)。
|
||||
|
||||
対応している内容は次のとおりです。
|
||||
|
||||
- **スクリプトヘッダの解釈**: コメント形式のパラメータ宣言を解釈し、スクリプト本体が参照する変数を実行前に定義します。
|
||||
- `--dialog:項目名,local 変数=既定値;…` … 各項目の宣言部(`local 変数=既定値` など)を本体の先頭に展開します。AviUtl では対話ダイアログで編集される値ですが、本プラグインでは既定値で動作します。
|
||||
- `--color:0xRRGGBB` … 変数 `color` を指定色で定義します。
|
||||
- `--check0:項目名,既定値` … `obj.check0`(`0`〜`3`)を既定値で定義します。
|
||||
- `--param:任意のLua文` … 記述した Lua 文をそのまま本体の先頭に展開します。
|
||||
- `--track0:`〜`--track3:` … トラックバーの値は従来どおり `obj.track0`〜`obj.track3` から参照します(ラベル・範囲・既定値の UI 反映は行いません)。
|
||||
- **`@` による複数セクション**: 1 つのスクリプトに `@名前` で複数の効果が定義されている場合、先頭のセクションのみを実行します。
|
||||
- **`obj.rand(st, ed [, seed [, frame]])`**: 指定範囲(`st`〜`ed`)の整数を返す決定論的な乱数です。`seed` と `frame` が同じであれば常に同じ値を返し、`frame` を省略すると現在のフレームを用います。従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)で同じ値を返します。
|
||||
- **`obj.load("figure", 名前, 色, サイズ [, ライン [, アスペクト]])`**: 円・四角形・三角形・五角形・六角形・星形を生成し、オブジェクトのバッファを置き換えて描画します(出力は図形サイズに合わせて生成され、中心に配置されます)。`ライン` を省略するか `0` で塗りつぶし、サイズ以上の値でも塗りつぶしになります。`アスペクト`(-1.0〜1.0)で幅・高さを歪曲できます。`figure` 以外の対象は本バージョンでは対象外です。描画系 API を含むスクリプトは従来エンジン(MoonSharp)で実行されます。
|
||||
|
||||
次のような機能は、本体の描画パイプラインへの統合を要するため、この互換層では対象外です(呼び出しを含むスクリプトは意図どおりには動作しません)。
|
||||
|
||||
- 描画・合成(`obj.draw` / `obj.drawpoly`)、`obj.load` の `"figure"` 以外の対象(画像ファイル・`"text"`・`"movie"` など)、および `obj.setfont`
|
||||
- フィルタ効果やバッファ操作(`obj.effect` / `obj.copybuffer` / `obj.setoption` など)
|
||||
- `require` によるモジュール読み込み、`io` などのファイルアクセス
|
||||
|
||||
---
|
||||
|
||||
## 実行モデル
|
||||
@@ -321,7 +345,7 @@ obj.alpha = anim.ease_out(t) * 255
|
||||
|
||||
## 注意事項
|
||||
|
||||
- **AviUtl 非対応**: 本プラグインは独自のスクリプト実行系であり、AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
- **AviUtl 互換は部分的**: AviUtl のアニメーション効果スクリプトのうち、変形・不透明度・乱数の範囲のみ実行できます([AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。描画・フィルタ・ファイルアクセス系の関数、および AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
- **実行タイムアウト**: スクリプトの実行は 5000ms(5秒)でタイムアウトし、超過した場合は強制終了されエラーとして扱われます。無限ループが発生しないよう注意してください。
|
||||
- **利用可能な標準ライブラリの制限**: `table`、`string`、`math`、`bit32` および基本関数のみ利用できます。`io`、`os`、`debug`、`ffi`、`require` は利用できません。
|
||||
- **ピクセル操作の負荷**: `obj.getpixel` / `obj.setpixel` / `obj.getpixeldata` は実際の入力画像にアクセスするため、各フレームで最初に呼び出した際に GPU→CPU へのデータ転送が発生します。不要な場合は呼び出しを省略することで処理を高速化できます。これらを含むスクリプトは高速ランタイム(LuaJIT)で自動実行され大幅に高速化されます。詳細は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照。
|
||||
|
||||
@@ -307,6 +307,26 @@ function anim.rand(...)
|
||||
return min + r * (max - min)
|
||||
end
|
||||
|
||||
function aviutl_rand(a, b, seed, frame)
|
||||
local ps = ffi.new("double[1]", seed)
|
||||
local ws = ffi.cast("uint32_t*", ps)
|
||||
local s = tou(bit.bxor(ws[0], ws[1]))
|
||||
local pf = ffi.new("double[1]", frame)
|
||||
local wf = ffi.cast("uint32_t*", pf)
|
||||
local f = tou(bit.bxor(wf[0], wf[1]))
|
||||
local h = tou(umul32(s, 374761393) + umul32(f, 668265263))
|
||||
h = umul32(tou(bit.bxor(h, bit.rshift(h, 13))), 1274126177)
|
||||
h = tou(bit.bxor(h, bit.rshift(h, 16)))
|
||||
local r = h / 4294967295.0
|
||||
local lo = floor(math.min(a, b))
|
||||
local hi = floor(math.max(a, b))
|
||||
local span = hi - lo + 1
|
||||
if span <= 1 then return lo end
|
||||
local v = lo + floor(r * span)
|
||||
if v > hi then return hi end
|
||||
return v
|
||||
end
|
||||
|
||||
local function noise_hash(x, y, z)
|
||||
local n = tou(umul32(tou(x), 374761393) + umul32(tou(y), 668265263) + umul32(tou(z), 1013904223))
|
||||
n = umul32(tou(bit.bxor(n, bit.rshift(n, 13))), 1274126177)
|
||||
|
||||
@@ -146,6 +146,10 @@ end
|
||||
|
||||
function obj.putpixeldata() end
|
||||
|
||||
function obj.rand(a, b, seed, frame)
|
||||
return aviutl_rand(a or 0, b or 0, seed or 0, frame or obj.frame or 0)
|
||||
end
|
||||
|
||||
local cacheTag, cacheFrame, cacheFound
|
||||
local cacheExist, cacheX, cacheY, cacheZ, cacheZoom, cacheRz, cacheAlpha, cacheLayer
|
||||
|
||||
@@ -223,6 +227,8 @@ local function loadFields()
|
||||
ymm4.is_saving = f64[48] ~= 0; ymm4.is_playing = f64[49] ~= 0; ymm4.is_paused = f64[50] ~= 0
|
||||
ymm4.group_ratio = (f64[44] ~= 0) and (f64[43] / f64[44]) or 0
|
||||
obj.timelineframe = f64[51]; obj.timelinetime = f64[52]
|
||||
obj.check0 = f64[53] ~= 0; obj.check1 = f64[54] ~= 0; obj.check2 = f64[55] ~= 0; obj.check3 = f64[56] ~= 0
|
||||
sandbox.color = (f64[57] >= 0) and f64[57] or nil
|
||||
end
|
||||
|
||||
local function storeFields()
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする