Class NinePatch
This class represents a texture with nine areas. A nine patch texture is useful if a big area should be covered by a small texture that has a specific outline, like a gui panel texture. The center of the texture will be stretched or tiled, while the outline of the texture will remain at its original size, keeping aspect ratios alive. The nine patch can then be drawn using NinePatchExtensions.
public class NinePatch : GenericDataHolder, IGenericDataHolder
- Inheritance
-
NinePatch
- Implements
- Inherited Members
- Extension Methods
Constructors
NinePatch(TextureRegion, Padding, NinePatchMode, bool)
Creates a new nine patch from a texture and a padding
public NinePatch(TextureRegion texture, Padding padding, NinePatchMode mode = NinePatchMode.Stretch, bool paddingPercent = false)
Parameters
textureTextureRegionThe texture to use
paddingPaddingThe padding that marks where the outline area stops in pixels, or as a percentage if
paddingPercentis truemodeNinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercentboolWhether the padding should represent a percentage of the underlying
texture's size, rather than an absolute pixel amount
NinePatch(TextureRegion, float, NinePatchMode, bool)
public NinePatch(TextureRegion texture, float padding, NinePatchMode mode = NinePatchMode.Stretch, bool paddingPercent = false)
Parameters
textureTextureRegionpaddingfloatmodeNinePatchModepaddingPercentbool
NinePatch(TextureRegion, float, float, float, float, NinePatchMode, bool)
Creates a new nine patch from a texture and a padding
public NinePatch(TextureRegion texture, float paddingLeft, float paddingRight, float paddingTop, float paddingBottom, NinePatchMode mode = NinePatchMode.Stretch, bool paddingPercent = false)
Parameters
textureTextureRegionThe texture to use
paddingLeftfloatThe padding on the left edge in pixels, or as a percentage if
paddingPercentis truepaddingRightfloatThe padding on the right edge in pixels, or as a percentage if
paddingPercentis truepaddingTopfloatThe padding on the top edge in pixels, or as a percentage if
paddingPercentis truepaddingBottomfloatThe padding on the bottom edge in pixels, or as a percentage if
paddingPercentis truemodeNinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercentboolWhether the padding should represent a percentage of the underlying
texture's size, rather than an absolute pixel amount
NinePatch(Texture2D, float, NinePatchMode, bool)
Creates a new nine patch from a texture and a uniform padding
public NinePatch(Texture2D texture, float padding, NinePatchMode mode = NinePatchMode.Stretch, bool paddingPercent = false)
Parameters
textureTexture2DThe texture to use
paddingfloatThe padding that each edge should have in pixels, or as a percentage if
paddingPercentis truemodeNinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercentboolWhether the padding should represent a percentage of the underlying
texture's size, rather than an absolute pixel amount
NinePatch(Texture2D, float, float, float, float, NinePatchMode, bool)
Creates a new nine patch from a texture and a padding
public NinePatch(Texture2D texture, float paddingLeft, float paddingRight, float paddingTop, float paddingBottom, NinePatchMode mode = NinePatchMode.Stretch, bool paddingPercent = false)
Parameters
textureTexture2DThe texture to use
paddingLeftfloatThe padding on the left edge in pixels, or as a percentage if
paddingPercentis truepaddingRightfloatThe padding on the right edge in pixels, or as a percentage if
paddingPercentis truepaddingTopfloatThe padding on the top edge in pixels, or as a percentage if
paddingPercentis truepaddingBottomfloatThe padding on the bottom edge in pixels, or as a percentage if
paddingPercentis truemodeNinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercentboolWhether the padding should represent a percentage of the underlying
texture's size, rather than an absolute pixel amount
Fields
Mode
The NinePatchMode that this nine patch should use for drawing
public readonly NinePatchMode Mode
Field Value
Padding
The padding in each direction that marks where the outline area stops, in pixels
public readonly Padding Padding
Field Value
Region
The texture region of this nine patch
public readonly TextureRegion Region
Field Value
SourceRectangles
The nine patches that result from the Padding
public readonly Rectangle[] SourceRectangles
Field Value
- Rectangle[]