Transitions: Wipe (left-to-right reveal), added to the App Settings picker
Test: WipeTransitionTests. Not pushed.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user