using MLEM.Extensions; using MLEM.Textures; using MonoGame.Extended.TextureAtlases; namespace MLEM.Extended.Extensions { /// /// 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 NinePatchRegion2D ToExtended(this NinePatch patch) { return new NinePatchRegion2D(patch.Region.ToExtended(), 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 TextureRegion2D ToExtended(this TextureRegion region) { return new TextureRegion2D(region.Name, region.Texture, region.U, region.V, region.Width, region.Height); } /// /// Converts a MonoGame.Extended to a MLEM . /// /// The nine patch to convert /// The converted nine patch public static NinePatch ToMlem(this NinePatchRegion2D patch) { return new NinePatch(((TextureRegion2D) patch).ToMlem(), patch.LeftPadding, patch.RightPadding, patch.TopPadding, patch.BottomPadding); } /// /// Converts a MonoGame.Extended to a MLEM . /// /// The nine patch to convert /// The converted nine patch public static TextureRegion ToMlem(this TextureRegion2D region) { return new TextureRegion(region.Texture, region.Bounds) {Name = region.Name}; } } }