C# Class Nez.Textures.Subtexture

represents a single element in a texture atlas consisting of a texture and the source rectangle for the frame
Show file Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
center Vector2
origin Vector2
sourceRect Microsoft.Xna.Framework.Rectangle
texture2D Microsoft.Xna.Framework.Graphics.Texture2D

Public Methods

Method Description
Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture ) : Microsoft.Xna.Framework
Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle sourceRect ) : Microsoft.Xna.Framework
Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle sourceRect, Vector2 origin ) : Microsoft.Xna.Framework
Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, float x, float y, float width, float height ) : Microsoft.Xna.Framework

convenience constructor that casts floats to ints for the sourceRect

Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, int x, int y, int width, int height ) : Microsoft.Xna.Framework
ToString ( ) : string
clone ( ) : Subtexture

clones the Subtexture

generateNinePatchRects ( Rectangle renderRect, Rectangle destArray, int marginLeft, int marginRight, int marginTop, int marginBottom ) : void

generates nine patch Rectangles. destArray should have 9 elements. renderRect is the final area in which the nine patch will be rendered. To just get the source rects for rendering pass in the Subtexture.sourceRect. Pass in a larger Rectangle to get final destination rendering Rectangles.

subtexturesFromAtlas ( Microsoft.Xna.Framework.Graphics.Texture2D texture, int cellWidth, int cellHeight, int cellOffset, int maxCellsToInclude = int.MaxValue ) : List

provides a List of subtextures given an atlas with equally spaced rows/columns of sprites

Method Details

Subtexture() public method

public Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture ) : Microsoft.Xna.Framework
texture Microsoft.Xna.Framework.Graphics.Texture2D
return Microsoft.Xna.Framework

Subtexture() public method

public Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle sourceRect ) : Microsoft.Xna.Framework
texture Microsoft.Xna.Framework.Graphics.Texture2D
sourceRect Microsoft.Xna.Framework.Rectangle
return Microsoft.Xna.Framework

Subtexture() public method

public Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle sourceRect, Vector2 origin ) : Microsoft.Xna.Framework
texture Microsoft.Xna.Framework.Graphics.Texture2D
sourceRect Microsoft.Xna.Framework.Rectangle
origin Vector2
return Microsoft.Xna.Framework

Subtexture() public method

convenience constructor that casts floats to ints for the sourceRect
public Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, float x, float y, float width, float height ) : Microsoft.Xna.Framework
texture Microsoft.Xna.Framework.Graphics.Texture2D Texture.
x float The x coordinate.
y float The y coordinate.
width float Width.
height float Height.
return Microsoft.Xna.Framework

Subtexture() public method

public Subtexture ( Microsoft.Xna.Framework.Graphics.Texture2D texture, int x, int y, int width, int height ) : Microsoft.Xna.Framework
texture Microsoft.Xna.Framework.Graphics.Texture2D
x int
y int
width int
height int
return Microsoft.Xna.Framework

ToString() public method

public ToString ( ) : string
return string

clone() public method

clones the Subtexture
public clone ( ) : Subtexture
return Subtexture

generateNinePatchRects() public method

generates nine patch Rectangles. destArray should have 9 elements. renderRect is the final area in which the nine patch will be rendered. To just get the source rects for rendering pass in the Subtexture.sourceRect. Pass in a larger Rectangle to get final destination rendering Rectangles.
public generateNinePatchRects ( Rectangle renderRect, Rectangle destArray, int marginLeft, int marginRight, int marginTop, int marginBottom ) : void
renderRect Microsoft.Xna.Framework.Rectangle Render rect.
destArray Microsoft.Xna.Framework.Rectangle Destination array.
marginLeft int Margin left.
marginRight int Margin right.
marginTop int Margin top.
marginBottom int Margin bottom.
return void

subtexturesFromAtlas() public static method

provides a List of subtextures given an atlas with equally spaced rows/columns of sprites
public static subtexturesFromAtlas ( Microsoft.Xna.Framework.Graphics.Texture2D texture, int cellWidth, int cellHeight, int cellOffset, int maxCellsToInclude = int.MaxValue ) : List
texture Microsoft.Xna.Framework.Graphics.Texture2D Texture.
cellWidth int Cell width.
cellHeight int Cell height.
cellOffset int the first cell to include while processing. 0 based indexing.
maxCellsToInclude int Max cells to included.
return List

Property Details

center public property

center of the sourceRect if it had a 0,0 origin. This is basically the center in sourceRect-space.
public Vector2 center
return Vector2

origin public property

the origin that a RenderableComponent should use when using this Subtexture. Defaults to the center.
public Vector2 origin
return Vector2

sourceRect public property

rectangle in the Texture2D for this element
public Rectangle,Microsoft.Xna.Framework sourceRect
return Microsoft.Xna.Framework.Rectangle

texture2D public property

the actual Texture2D
public Texture2D,Microsoft.Xna.Framework.Graphics texture2D
return Microsoft.Xna.Framework.Graphics.Texture2D