Table of Contents

Class TextureRegion

Namespace
MLEM.Textures
Assembly
MLEM.dll

This class represents a part of a texture.

public class TextureRegion : GenericDataHolder, IGenericDataHolder
Inheritance
TextureRegion
Implements
Inherited Members

Constructors

TextureRegion(TextureRegion, Point, Point)

Creates a new texture region which is a sub-region of the given texture region

public TextureRegion(TextureRegion region, Point uv, Point size)

Parameters

region TextureRegion

The texture region to create a sub-region of

uv Point

The top left corner of this area

size Point

The size of this area

TextureRegion(TextureRegion, Rectangle)

Creates a new texture region which is a sub-region of the given texture region

public TextureRegion(TextureRegion region, Rectangle area)

Parameters

region TextureRegion

The texture region to create a sub-region of

area Rectangle

The new texture region area

TextureRegion(TextureRegion, int, int, int, int)

Creates a new texture region which is a sub-region of the given texture region

public TextureRegion(TextureRegion region, int u, int v, int width, int height)

Parameters

region TextureRegion

The texture region to create a sub-region of

u int

The x coordinate of the top left corner of this area

v int

The y coordinate of the top left corner of this area

width int

The width of this area

height int

The height of this area

TextureRegion(Texture2D)

Creates a new texture region that spans the entire texture

public TextureRegion(Texture2D texture)

Parameters

texture Texture2D

The texture to use

TextureRegion(Texture2D, Point, Point)

Creates a new texture region based on a texture, a position and a size

public TextureRegion(Texture2D texture, Point uv, Point size)

Parameters

texture Texture2D

The texture to use

uv Point

The top left corner of this area

size Point

The size of this area

TextureRegion(Texture2D, Rectangle)

Creates a new texture region from a texture and a rectangle which defines the region's area

public TextureRegion(Texture2D texture, Rectangle area)

Parameters

texture Texture2D

The texture to use

area Rectangle

The area that this texture region should cover

TextureRegion(Texture2D, int, int, int, int)

Creates a new texture region based on a texture and area coordinates

public TextureRegion(Texture2D texture, int u, int v, int width, int height)

Parameters

texture Texture2D

The texture to use

u int

The x coordinate of the top left corner of this area

v int

The y coordinate of the top left corner of this area

width int

The width of this area

height int

The height of this area

Fields

Area

The area that is covered by this texture region

public readonly Rectangle Area

Field Value

Rectangle

Name

The name of this texture region. By default, this name is Empty.

public string Name

Field Value

string

Pivot

The pivot point of this texture region, where 0, 0 is the top left and 1, 1 is the bottom right of the texture. When drawing, this will be seen as the origin from where to start drawing.

public Vector2 Pivot

Field Value

Vector2

Source

A TextureRegion that this texture region was created from. This value is set in the various constructors that accept another TextureRegion to create sub-regions from, in OffsetCopy(Point), as well as by MLEM.Data's RuntimeTexturePacker.

public TextureRegion Source

Field Value

TextureRegion

Texture

The texture that this region is a part of

public readonly Texture2D Texture

Field Value

Texture2D

Properties

Height

The height of this texture region

public int Height { get; }

Property Value

int

PivotPixels

The Pivot of this texture region, but in absolute pixels rather than percentage.

public Vector2 PivotPixels { get; set; }

Property Value

Vector2

Position

The top left corner of this texture region

public Point Position { get; }

Property Value

Point

Size

The size of this texture region

public Point Size { get; }

Property Value

Point

U

The x coordinate of the top left corner of this texture region

public int U { get; }

Property Value

int

V

The y coordinate of the top left corner of this texture region

public int V { get; }

Property Value

int

Width

The width of this texture region

public int Width { get; }

Property Value

int

Methods

OffsetCopy(Point)

Returns a new TextureRegion that has the same Texture, Pivot and Size as this texture, but the returned region's Position will be offset by offset. Note that the Name is not preserved in the copy.

public TextureRegion OffsetCopy(Point offset)

Parameters

offset Point

The offset to apply to the Position

Returns

TextureRegion

An offset copy of this texture region