diff --git a/source/MonoGame.Extended/Graphics/NinePatch.cs b/source/MonoGame.Extended/Graphics/NinePatch.cs index 25d1ce62..7a9e1069 100644 --- a/source/MonoGame.Extended/Graphics/NinePatch.cs +++ b/source/MonoGame.Extended/Graphics/NinePatch.cs @@ -62,6 +62,9 @@ public class NinePatch /// public string Name { get; } + /// + /// The size of the border patches around the middle patch. + /// public Thickness Padding { get; } /// @@ -90,7 +93,11 @@ public class NinePatch /// /// Initializes a new instance of the class with the specified patches and name. /// - /// An array of nine objects. + /// + /// An array of nine objects. + /// The top, left, bottom and right regions must to be of exactly the same size. + /// Mid patches can be as small as 1x1. + /// /// /// The name of the nine-patch. If null or empty, a default name will be generated based on the texture name of the /// top-left patch. @@ -113,8 +120,11 @@ public class NinePatch } _patches = patches; - Rectangle mid = patches[NinePatch.Middle].Bounds; - Padding = new Thickness(mid.Left, mid.Top, mid.Right, mid.Bottom); + + Size topLeft = patches[NinePatch.TopLeft].Size; + Size bottomRight = patches[NinePatch.BottomRight].Size; + Padding = new Thickness(topLeft.Width, topLeft.Height, bottomRight.Width, bottomRight.Height); + Name = name; } }