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
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
texture
TextureRegionThe texture to use
padding
PaddingThe padding that marks where the outline area stops in pixels, or as a percentage if
paddingPercent
is truemode
NinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercent
boolWhether 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
texture
TextureRegionpadding
floatmode
NinePatchModepaddingPercent
bool
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
texture
TextureRegionThe texture to use
paddingLeft
floatThe padding on the left edge in pixels, or as a percentage if
paddingPercent
is truepaddingRight
floatThe padding on the right edge in pixels, or as a percentage if
paddingPercent
is truepaddingTop
floatThe padding on the top edge in pixels, or as a percentage if
paddingPercent
is truepaddingBottom
floatThe padding on the bottom edge in pixels, or as a percentage if
paddingPercent
is truemode
NinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercent
boolWhether 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
texture
Texture2DThe texture to use
padding
floatThe padding that each edge should have in pixels, or as a percentage if
paddingPercent
is truemode
NinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercent
boolWhether 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
texture
Texture2DThe texture to use
paddingLeft
floatThe padding on the left edge in pixels, or as a percentage if
paddingPercent
is truepaddingRight
floatThe padding on the right edge in pixels, or as a percentage if
paddingPercent
is truepaddingTop
floatThe padding on the top edge in pixels, or as a percentage if
paddingPercent
is truepaddingBottom
floatThe padding on the bottom edge in pixels, or as a percentage if
paddingPercent
is truemode
NinePatchModeThe mode to use for drawing this nine patch, defaults to Stretch
paddingPercent
boolWhether 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[]