Renamed Sce to SceneFader

This commit is contained in:
2026-06-13 21:31:35 +02:00
parent 24926d01d3
commit 3d78eb5679
4 changed files with 18 additions and 17 deletions

View File

@@ -0,0 +1,77 @@
using System.Drawing;
using System.Drawing.Imaging;
namespace _2DGAMELIB
{
//Basically used to animate switching between two static images
public class SceneFader
{
private Bitmap Start;
private Graphics GS;
private Bitmap End;
private Graphics GE;
private int w;
private int h;
private System.Drawing.Rectangle r;
private ColorMatrix cm = new ColorMatrix();
private ImageAttributes ia = new ImageAttributes();
public SceneFader(int Width, int Height)
{
w = Width;
h = Height;
Start = new Bitmap(w, h);
GS = Graphics.FromImage(Start);
End = new Bitmap(w, h);
GE = Graphics.FromImage(End);
r = new System.Drawing.Rectangle(0, 0, w, h);
}
public void TransformAlpha(Graphics Graphics, double Rate)
{
Graphics.DrawImage(Start, 0, 0);
cm.Matrix33 = (float)Rate;
ia.SetColorMatrix(cm);
Graphics.DrawImage(End, r, 0, 0, w, h, GraphicsUnit.Pixel, ia);
}
public void TransD(Graphics Graphics, double Rate)
{
Graphics.DrawImage(End, 0, 0);
cm.Matrix33 = (float)Rate.Inverse();
ia.SetColorMatrix(cm);
Graphics.DrawImage(Start, r, 0, 0, w, h, GraphicsUnit.Pixel, ia);
}
public void DrawStart(RenderArea Are)
{
Are.DrawTo(GS);
}
public void DrawEnd(RenderArea Are)
{
Are.DrawTo(GE);
}
public void ClearStart(ref Color ClearColor)
{
GS.Clear(ClearColor);
}
public void Dispose()
{
Start.Dispose();
GS.Dispose();
End.Dispose();
GE.Dispose();
ia.Dispose();
}
}
}