2019-08-06 14:26:51 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2019-11-02 14:53:59 +01:00
|
|
|
using MLEM.Extensions;
|
|
|
|
using MLEM.Textures;
|
|
|
|
using MonoGame.Extended;
|
2019-08-06 14:26:51 +02:00
|
|
|
using MonoGame.Extended.BitmapFonts;
|
|
|
|
|
|
|
|
namespace MLEM.Extended.Extensions {
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A set of extension methods for dealing with <see cref="SpriteBatch"/> and <see cref="RectangleF"/> in combination.
|
|
|
|
/// </summary>
|
2019-08-06 14:26:51 +02:00
|
|
|
public static class SpriteBatchExtensions {
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color,float,Vector2,SpriteEffects,float)"/>
|
2019-11-02 14:53:59 +01:00
|
|
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
|
|
|
|
batch.Draw(texture, destinationRectangle.ToMlem(), sourceRectangle, color, rotation, origin, effects, layerDepth);
|
|
|
|
}
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color)"/>
|
2019-11-02 14:53:59 +01:00
|
|
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
|
|
|
|
batch.Draw(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
|
|
|
|
}
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Color)"/>
|
2019-11-02 14:53:59 +01:00
|
|
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
|
|
|
|
batch.Draw(texture, destinationRectangle, null, color);
|
|
|
|
}
|
|
|
|
|
2019-08-06 14:26:51 +02:00
|
|
|
}
|
|
|
|
}
|