Transitions: Wipe (left-to-right reveal), added to the App Settings picker

Test: WipeTransitionTests. Not pushed.
This commit is contained in:
2026-10-27 09:12:59 -07:00
parent f67a263ccd
commit b86b6bb601
4 changed files with 52 additions and 2 deletions
+25 -1
View File
@@ -10,7 +10,8 @@ public enum TransitionType
{
Cut,
Fade,
Move
Move,
Wipe
}
/// <summary>
@@ -102,10 +103,33 @@ public sealed class TransitionService
{
TransitionType.Fade => BlendFade(FromFrame, toFrame, t),
TransitionType.Move => BlendMove(FromFrame, toFrame, t),
TransitionType.Wipe => BlendWipe(FromFrame, toFrame, t),
_ => toFrame
};
}
/// <summary>Left-to-right reveal: the new scene sweeps in across the frame.</summary>
private static VideoFrame BlendWipe(VideoFrame from, VideoFrame to, float t)
{
var w = from.Width;
var h = from.Height;
var output = new byte[w * h * 4];
var edge = (int)Math.Round(Math.Clamp(t, 0f, 1f) * w);
for (var y = 0; y < h; y++)
{
for (var x = 0; x < w; x++)
{
var src = x < edge ? to.BgraPixels : from.BgraPixels;
var i = (y * w + x) * 4;
output[i] = src[i];
output[i + 1] = src[i + 1];
output[i + 2] = src[i + 2];
output[i + 3] = src[i + 3];
}
}
return new VideoFrame(w, h, output);
}
private static VideoFrame BlendFade(VideoFrame from, VideoFrame to, float t)
{
var w = from.Width;