Class TextureRegion
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
TextureRegionThe texture region to create a sub-region of
uv
PointThe top left corner of this area
size
PointThe 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
TextureRegionThe texture region to create a sub-region of
area
RectangleThe 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
TextureRegionThe texture region to create a sub-region of
u
intThe x coordinate of the top left corner of this area
v
intThe y coordinate of the top left corner of this area
width
intThe width of this area
height
intThe height of this area
TextureRegion(Texture2D)
Creates a new texture region that spans the entire texture
public TextureRegion(Texture2D texture)
Parameters
texture
Texture2DThe 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
Texture2DThe texture to use
uv
PointThe top left corner of this area
size
PointThe 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
Texture2DThe texture to use
area
RectangleThe 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
Texture2DThe texture to use
u
intThe x coordinate of the top left corner of this area
v
intThe y coordinate of the top left corner of this area
width
intThe width of this area
height
intThe 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
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
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
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
V
The y coordinate of the top left corner of this texture region
public int V { get; }
Property Value
Width
The width of this texture region
public int Width { get; }
Property Value
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
PointThe offset to apply to the Position
Returns
- TextureRegion
An offset copy of this texture region