using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using RhythmBullet.Zer01HD.Utilities.UI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RhythmBullet.Zer01HD.Game.Screens.Transitions { internal class FadeInTransition : IDisposable { public readonly Texture2D curtain; Rectangle curtainSize; Color color; private float progR, progG, progB, progA; private float rR, rG, rB, rA; private bool recorded; internal FadeInTransition(GraphicsDevice graphicsDevice, Color startColor, Vector2 dimensions) { curtain = new Texture2D(graphicsDevice, 1, 1); curtain.SetData(new[] { startColor }); curtainSize.Width = (int)dimensions.X; curtainSize.Height = (int)dimensions.Y; color = startColor; } internal bool Fade(float deltaf) { if (progR > 0 || progG > 0 || progB > 0) { if (!recorded) { rR = (0 - color.R) / 1f; rG = (0 - color.G) / 1f; rB = (0 - color.B) / 1f; rA = (0 - color.A) / 1f; recorded = true; } progR += rR * deltaf; progR = Math.Max(progR, 0); progG += rG * deltaf; progG = Math.Max(progG, 0); progB += rB * deltaf; progB = Math.Max(progB, 0); progA += rA * deltaf; progA = Math.Max(progA, 0); color.R = (byte)progR; color.G = (byte)progG; color.B = (byte)progB; color.A = (byte)progA; return false; } return true; } internal void Draw(SpriteBatch batch) { if (curtain != null) { batch.Draw(curtain, curtainSize, color); } } public void Dispose() { curtain.Dispose(); } } }