using MLEM.Maths;
using MLEM.Textures;
using MonoGame.Extended.Graphics;
using NinePatch = MLEM.Textures.NinePatch;
using ExtNinePatch = MonoGame.Extended.Graphics.NinePatch;
namespace MLEM.Extended.Graphics {
///
/// A set of extensions for converting texture-related types between MLEM and MonoGame.Extended.
///
public static class TextureExtensions {
///
/// Converts a MLEM to a MonoGame.Extended .
///
/// The nine patch to convert
/// The converted nine patch
public static ExtNinePatch ToExtended(this NinePatch patch) {
return patch.Region.ToExtended().CreateNinePatch(patch.Padding.Left.Floor(), patch.Padding.Top.Floor(), patch.Padding.Right.Floor(), patch.Padding.Bottom.Floor());
}
///
/// Converts a MLEM to a MonoGame.Extended .
///
/// The nine patch to convert
/// The converted nine patch
public static Texture2DRegion ToExtended(this TextureRegion region) {
return new Texture2DRegion(region.Texture, region.U, region.V, region.Width, region.Height, region.Name);
}
///
/// Converts a MonoGame.Extended to a MLEM .
///
/// The nine patch to convert
/// The converted nine patch
public static TextureRegion ToMlem(this Texture2DRegion region) {
return new TextureRegion(region.Texture, region.Bounds) {Name = region.Name};
}
}
}