Table of Contents

Class TextureRegion

Namespace
Myra.Graphics2D.TextureAtlases
Assembly
Myra.dll

Represents a rectangular region within a texture.

public class TextureRegion : IImage, IBrush
Inheritance
TextureRegion
Implements
Derived
Inherited Members
Extension Methods

Constructors

TextureRegion(Texture2D)

Initializes a new instance of the TextureRegion class that covers the whole texture.

public TextureRegion(Texture2D texture)

Parameters

texture Texture2D

The texture to use.

TextureRegion(Texture2D, Rectangle)

Initializes a new instance of the TextureRegion class with the specified texture and bounds.

public TextureRegion(Texture2D texture, Rectangle bounds)

Parameters

texture Texture2D

The texture to use.

bounds Rectangle

The bounds of the region within the texture.

Exceptions

ArgumentNullException

texture is null.

TextureRegion(TextureRegion, Rectangle)

Initializes a new instance of the TextureRegion class based on another region with an offset bounds.

public TextureRegion(TextureRegion region, Rectangle bounds)

Parameters

region TextureRegion

The source texture region.

bounds Rectangle

The new bounds relative to the source region.

Exceptions

ArgumentNullException

region is null.

Properties

Bounds

Gets the bounds of the texture region.

public Rectangle Bounds { get; }

Property Value

Rectangle

Name

Gets or sets the name of the texture region.

public string Name { get; set; }

Property Value

string

Size

Gets the size of the texture region.

public Point Size { get; }

Property Value

Point

Texture

Gets the texture that contains this region.

public Texture2D Texture { get; }

Property Value

Texture2D

Methods

Draw(RenderContext, Rectangle, Color)

Draws the texture region to the specified render context at the given destination.

public virtual void Draw(RenderContext context, Rectangle dest, Color color)

Parameters

context RenderContext

The render context to draw to.

dest Rectangle

The destination rectangle where the region will be drawn.

color Color

The color to blend with the texture.

ToString()

Returns the name of the texture region.

public override string ToString()

Returns

string

The region name.