Skip to main content

TextureRegion

Namespace: MonineEngine.Graphics

Represents a rectangular region within a texture.

public class TextureRegion

Inheritance ObjectTextureRegion
Attributes NullableContextAttribute, NullableAttribute

Properties

Texture

Gets or sets the texture this region is part of.

public Texture2D Texture { get; set; }

Property Value

Texture2D

SourceRectangle

Gets or sets the boundary of this texture region within TextureRegion.Texture.

public Rectangle SourceRectangle { get; set; }

Property Value

Rectangle

Width

Gets the width, of this texture region in pixels.

public int Width { get; }

Property Value

Int32

Height

Gets the height of this texture region in pixels.

public int Height { get; }

Property Value

Int32

Constructors

TextureRegion()

Creates a new TextureRegion. Properties must be specified after creation if using this constructor.

public TextureRegion()

TextureRegion(Texture2D)

Creates a new TextureRegion using the specified texture.

public TextureRegion(Texture2D texture)

Parameters

texture Texture2D
The texture to use as the source texture.

TextureRegion(Texture2D, Rectangle)

Creates a new TextureRegion using the specified texture and bounds.

public TextureRegion(Texture2D texture, Rectangle bounds)

Parameters

texture Texture2D
The texture to use as the source texture.

bounds Rectangle
The bounds of the region.

TextureRegion(Texture2D, Int32, Int32, Int32, Int32)

Creates a new TextureRegion using the specified source texture and properties.

public TextureRegion(Texture2D texture, int x, int y, int width, int height)

Parameters

texture Texture2D
The texture to use as the source texture.

x Int32
The x-coordinate position of the upper-left corner of this texture region relative to the upper-left corner of the source texture.

y Int32
The y-coordinate position of the upper-left corner of this texture region relative to the upper-left corner of the source texture.

width Int32
The width, in pixels, of this texture region.

height Int32
The height, in pixels, of this texture region.

Methods

Draw(IRendererService, Vector2, Color)

Submit this texture region for drawing in the current batch.

public void Draw(IRendererService service, Vector2 position, Color color)

Parameters

service IRendererService
The RendererService of the current .

position Vector2
The xy-coordinate location to draw this texture region on the screen.

color Color
The color mask to apply when drawing this texture region on screen.

Draw(IRendererService, Vector2, Color, Single, Vector2, Single, SpriteEffects, Single)

Submit this texture region for drawing in the current batch.

public void Draw(IRendererService service, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)

Parameters

service IRendererService
The RendererService of the current .

position Vector2
The xy-coordinate location to draw this texture region on the screen.

color Color
The color mask to apply when drawing this texture region on screen.

rotation Single
The amount of rotation, in radians, to apply when drawing this texture region on screen.

origin Vector2
The center of rotation, scaling, and position when drawing this texture region on screen.

scale Single
The scale factor to apply when drawing this texture region on screen.

effects SpriteEffects
Specifies if this texture region should be flipped horizontally, vertically, or both when drawing on screen.

layerDepth Single
The depth of the layer to use when drawing this texture region on screen.

Draw(IRendererService, Vector2, Color, Single, Vector2, Vector2, SpriteEffects, Single)

Submit this texture region for drawing in the current batch.

public void Draw(IRendererService service, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)

Parameters

service IRendererService
The RendererService of the current .

position Vector2
The xy-coordinate location to draw this texture region on the screen.

color Color
The color mask to apply when drawing this texture region on screen.

rotation Single
The amount of rotation, in radians, to apply when drawing this texture region on screen.

origin Vector2
The center of rotation, scaling, and position when drawing this texture region on screen.

scale Vector2
The amount of scaling to apply to the x- and y-axes when drawing this texture region on screen.

effects SpriteEffects
Specifies if this texture region should be flipped horizontally, vertically, or both when drawing on screen.

layerDepth Single
The depth of the layer to use when drawing this texture region on screen.