Table of Contents

Class NinePatch

Namespace
MLEM.Textures
Assembly
MLEM.dll

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

texture TextureRegion

The texture to use

padding Padding

The padding that marks where the outline area stops in pixels, or as a percentage if paddingPercent is true

mode NinePatchMode

The mode to use for drawing this nine patch, defaults to Stretch

paddingPercent bool

Whether 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 TextureRegion
padding float
mode NinePatchMode
paddingPercent 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 TextureRegion

The texture to use

paddingLeft float

The padding on the left edge in pixels, or as a percentage if paddingPercent is true

paddingRight float

The padding on the right edge in pixels, or as a percentage if paddingPercent is true

paddingTop float

The padding on the top edge in pixels, or as a percentage if paddingPercent is true

paddingBottom float

The padding on the bottom edge in pixels, or as a percentage if paddingPercent is true

mode NinePatchMode

The mode to use for drawing this nine patch, defaults to Stretch

paddingPercent bool

Whether 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 Texture2D

The texture to use

padding float

The padding that each edge should have in pixels, or as a percentage if paddingPercent is true

mode NinePatchMode

The mode to use for drawing this nine patch, defaults to Stretch

paddingPercent bool

Whether 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 Texture2D

The texture to use

paddingLeft float

The padding on the left edge in pixels, or as a percentage if paddingPercent is true

paddingRight float

The padding on the right edge in pixels, or as a percentage if paddingPercent is true

paddingTop float

The padding on the top edge in pixels, or as a percentage if paddingPercent is true

paddingBottom float

The padding on the bottom edge in pixels, or as a percentage if paddingPercent is true

mode NinePatchMode

The mode to use for drawing this nine patch, defaults to Stretch

paddingPercent bool

Whether 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

NinePatchMode

Padding

The padding in each direction that marks where the outline area stops, in pixels

public readonly Padding Padding

Field Value

Padding

Region

The texture region of this nine patch

public readonly TextureRegion Region

Field Value

TextureRegion

SourceRectangles

The nine patches that result from the Padding

public readonly Rectangle[] SourceRectangles

Field Value

Rectangle[]