SpriteBatcherAtlasExtensions.DrawFromAtlas Method
Definition¶
Namespace: Brine2D.Rendering.TextureAtlas
| Overloads | |
|---|---|
| DrawFromAtlas(this SpriteBatcher, ITextureAtlas, string, Vector2, Nullable<Vector2>, float, Nullable<Vector2>, Nullable<Color>, byte, SpriteFlip) | Draws a sprite from a texture atlas by name. Convenience method that looks up the region and draws it in one call. |
| DrawFromAtlas(this SpriteBatcher, ITextureAtlasCollection, string, Vector2, Nullable<Vector2>, float, Nullable<Vector2>, Nullable<Color>, byte, SpriteFlip) | Draws a sprite from a texture atlas collection by name. Convenience method that looks up the region automatically across all atlases. |
SpriteBatcherAtlasExtensions.DrawFromAtlas(this SpriteBatcher, ITextureAtlas, string, Vector2, Nullable\<Vector2>, float, Nullable\<Vector2>, Nullable\<Color>, byte, SpriteFlip) Method¶
Draws a sprite from a texture atlas by name. Convenience method that looks up the region and draws it in one call.
public static bool DrawFromAtlas(this Brine2D.Rendering.SpriteBatcher batcher, Brine2D.Rendering.TextureAtlas.ITextureAtlas atlas, string regionName, System.Numerics.Vector2 position, System.Nullable<System.Numerics.Vector2> scale=null, float rotation=0f, System.Nullable<System.Numerics.Vector2> origin=null, System.Nullable<Brine2D.Core.Color> tint=null, byte layer=0, Brine2D.Rendering.SpriteFlip flip=Brine2D.Rendering.SpriteFlip.None);
Parameters¶
batcher SpriteBatcher
atlas ITextureAtlas
The texture atlas.
regionName System.String
Name of the region to draw.
position System.Numerics.Vector2
World position of the sprite.
scale System.Nullable<System.Numerics.Vector2>
Scale to apply to the sprite (default: 1,1).
rotation System.Single
Rotation in radians (default: 0).
origin System.Nullable<System.Numerics.Vector2>
Origin point for rotation/scaling (0-1 range, default: center).
Color tint to apply (default: white).
layer System.Byte
Rendering layer (default: 0).
flip SpriteFlip
Sprite flip flags (default: none).
Returns¶
System.Boolean
True if the region was found and drawn; false otherwise.
Remarks¶
This method performs a dictionary lookup by name each time it's called. For optimal performance in tight loops, cache the region first:
var enemyRegion = atlas.GetRegion("enemy");
foreach (var position in enemyPositions)
{
batcher.DrawAtlasRegion(enemyRegion, position);
}
Use this method for one-off draws, prototyping, or when drawing different sprites each frame.
SpriteBatcherAtlasExtensions.DrawFromAtlas(this SpriteBatcher, ITextureAtlasCollection, string, Vector2, Nullable\<Vector2>, float, Nullable\<Vector2>, Nullable\<Color>, byte, SpriteFlip) Method¶
Draws a sprite from a texture atlas collection by name. Convenience method that looks up the region automatically across all atlases.
public static bool DrawFromAtlas(this Brine2D.Rendering.SpriteBatcher batcher, Brine2D.Rendering.TextureAtlas.ITextureAtlasCollection atlasCollection, string regionName, System.Numerics.Vector2 position, System.Nullable<System.Numerics.Vector2> scale=null, float rotation=0f, System.Nullable<System.Numerics.Vector2> origin=null, System.Nullable<Brine2D.Core.Color> tint=null, byte layer=0, Brine2D.Rendering.SpriteFlip flip=Brine2D.Rendering.SpriteFlip.None);
Parameters¶
batcher SpriteBatcher
atlasCollection ITextureAtlasCollection
The texture atlas collection.
regionName System.String
Name of the region to draw.
position System.Numerics.Vector2
World position of the sprite.
scale System.Nullable<System.Numerics.Vector2>
Scale to apply to the sprite (default: 1,1).
rotation System.Single
Rotation in radians (default: 0).
origin System.Nullable<System.Numerics.Vector2>
Origin point for rotation/scaling (0-1 range, default: center).
Color tint to apply (default: white).
layer System.Byte
Rendering layer (default: 0).
flip SpriteFlip
Sprite flip flags (default: none).
Returns¶
System.Boolean
True if the region was found and drawn; false otherwise.
Remarks¶
This method performs a dictionary lookup by name each time it's called. For optimal performance in tight loops, cache the region first:
var enemyRegion = atlasCollection.GetRegion("enemy");
foreach (var position in enemyPositions)
{
batcher.DrawAtlasRegion(enemyRegion, position);
}
Use this method for one-off draws, prototyping, or when drawing different sprites each frame.