summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs')
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs
new file mode 100644
index 0000000..32a8cca
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended/Screens/Transitions/ExpandTransition.cs
@@ -0,0 +1,42 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace MonoGame.Extended.Screens.Transitions
+{
+ public class ExpandTransition : Transition
+ {
+ private readonly GraphicsDevice _graphicsDevice;
+ private readonly SpriteBatch _spriteBatch;
+
+ public ExpandTransition(GraphicsDevice graphicsDevice, Color color, float duration = 1.0f)
+ : base(duration)
+ {
+ Color = color;
+
+ _graphicsDevice = graphicsDevice;
+ _spriteBatch = new SpriteBatch(graphicsDevice);
+ }
+
+ public override void Dispose()
+ {
+ _spriteBatch.Dispose();
+ }
+
+ public Color Color { get; }
+
+ public override void Draw(GameTime gameTime)
+ {
+ var halfWidth = _graphicsDevice.Viewport.Width / 2f;
+ var halfHeight = _graphicsDevice.Viewport.Height / 2f;
+ var x = halfWidth * (1.0f - Value);
+ var y = halfHeight * (1.0f - Value);
+ var width = _graphicsDevice.Viewport.Width * Value;
+ var height = _graphicsDevice.Viewport.Height * Value;
+ var rectangle = new RectangleF(x, y, width, height);
+
+ _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
+ _spriteBatch.FillRectangle(rectangle, Color);
+ _spriteBatch.End();
+ }
+ }
+} \ No newline at end of file