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
textureTexture2DThe 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
textureTexture2DThe texture to use.
boundsRectangleThe bounds of the region within the texture.
Exceptions
- ArgumentNullException
textureis 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
regionTextureRegionThe source texture region.
boundsRectangleThe new bounds relative to the source region.
Exceptions
- ArgumentNullException
regionis 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
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
contextRenderContextThe render context to draw to.
destRectangleThe destination rectangle where the region will be drawn.
colorColorThe color to blend with the texture.
ToString()
Returns the name of the texture region.
public override string ToString()
Returns
- string
The region name.