Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Drawing.Tilesheets.Tilesheet Class Referencesealed

Represents a tilesheet image and metadata for rendering tiles. More...

Inheritance diagram for Gondwana.Drawing.Tilesheets.Tilesheet:

Public Member Functions

TilesheetRegion AddRegion (string name, Rectangle area, Size tileSize, Spacing? tilePadding=null, Spacing? regionMargin=null, Spacing? overhangPixels=null, CollisionAdjust? collisionAdjust=null, TileCollisionType collisionType=TileCollisionType.None)
 Adds a region with the supplied default collision adjustment and collision type.
TilesheetRegion? GetRegion (string name)
 Finds a tilesheet region by its case-insensitive name.
bool RemoveRegion (string name, bool dispose=true)
 Removes the named tilesheet region and optionally disposes it.
Frame GetFrame (string regionName, int x, int y)
 Creates a frame reference at the specified tile coordinates.
Frame GetFrame (int x, int y)
 Creates a frame reference at the specified tile coordinates.
void ApplyMask (SKColor? maskColor=null, byte tolerance=5)
 Applies a color-key transparency mask and rebuilds the frame cache.
void ApplyPremultiplyAlpha ()
 Premultiplies the bitmap alpha and rebuilds the frame cache.
byte[] ToByteArray (SKEncodedImageFormat format=SKEncodedImageFormat.Png, int quality=100)
 Encodes the tilesheet bitmap using the requested image format and quality.
void PersistImageToFile (string imageFilePath, SKEncodedImageFormat format=SKEncodedImageFormat.Png, int quality=100)
 Persists this tilesheet's source image to a file and promotes the tilesheet from a runtime-only bitmap to a file-backed tilesheet.
SKImage? GetImage (string regionName, int x, int y)
 Gets the cached image for the specified frame.
SKBitmap? GetBitmap (string regionName, int x, int y)
 Gets the cached bitmap for the specified frame.
Dictionary<(string regionName, int x, int y), SKBitmap > GetAllBitmaps ()
 Collects the cached frame bitmaps indexed by their tile coordinates.
Dictionary<(string regionName, int x, int y), SKImage > GetAllImages ()
 Collects the cached frame images indexed by their tile coordinates.
void Dispose ()
 Releases the resources owned by this instance.

Properties

SKBitmap SkBitmap = null! [get]
 Gets the current tilesheet bitmap used for rendering.
SKBitmap? SkBitmapOriginal [get]
 Gets the source bitmap retained before masking or alpha conversion.
string Name = string.Empty [get, set]
 Gets the name.
List< TilesheetRegion > Regions = new() [get]
 Gets the named frame regions in the tilesheet.
TilesheetRegion DefaultRegion [get]
 Gets the default tilesheet region.
TypedValueBag ValueBag = new() [get, set]
 Gets or sets the custom typed values associated with this object.
AssetsFileIdentifier? AssetIdentifier [get]
 Gets the packed asset from which the image was loaded, if any.
string ImageFilePath = string.Empty [get]
 Gets the loose source image path, when available.
SKColor? MaskColor [get]
 Gets the color used for transparency masking.
byte MaskTolerance = 5 [get]
 Gets the per-channel tolerance used for transparency masking.
bool Premultiplied [get]
 Gets whether alpha premultiplication has been applied.
TilesheetRegion this[string regionName] [get]
 Gets the named tilesheet region.
Frame this[string regionName, int x, int y] [get]
 Gets a frame reference at the specified tile coordinates.
Frame this[int x, int y] [get]
 Gets a frame reference at the specified tile coordinates.

Events

Action< Tilesheet >? Disposed
 Occurs after the object releases its resources.

Detailed Description

Represents a tilesheet image and metadata for rendering tiles.

Definition at line 13 of file Tilesheet.cs.

Member Function Documentation

◆ AddRegion()

TilesheetRegion Gondwana.Drawing.Tilesheets.Tilesheet.AddRegion ( string name,
Rectangle area,
Size tileSize,
Spacing? tilePadding = null,
Spacing? regionMargin = null,
Spacing? overhangPixels = null,
CollisionAdjust? collisionAdjust = null,
TileCollisionType collisionType = TileCollisionType::None )

Adds a region with the supplied default collision adjustment and collision type.

Parameters
nameThe name.
areaThe area.
tileSizeThe tile size.
tilePaddingThe tile padding.
regionMarginThe region margin.
overhangPixelsThe overhang pixels.
collisionAdjustThe adjustment applied to the frame's collision bounds.
collisionTypeThe collision type.
Returns
The region added to the tilesheet.

Definition at line 210 of file Tilesheet.cs.

◆ ApplyMask()

void Gondwana.Drawing.Tilesheets.Tilesheet.ApplyMask ( SKColor? maskColor = null,
byte tolerance = 5 )

Applies a color-key transparency mask and rebuilds the frame cache.

Parameters
maskColorThe color to make transparent; null uses the default mask color.
toleranceThe tolerance.

Definition at line 304 of file Tilesheet.cs.

◆ ApplyPremultiplyAlpha()

void Gondwana.Drawing.Tilesheets.Tilesheet.ApplyPremultiplyAlpha ( )

Premultiplies the bitmap alpha and rebuilds the frame cache.

Definition at line 346 of file Tilesheet.cs.

◆ Dispose()

void Gondwana.Drawing.Tilesheets.Tilesheet.Dispose ( )

Releases the resources owned by this instance.

Definition at line 554 of file Tilesheet.cs.

◆ GetAllBitmaps()

Dictionary<(string regionName, int x, int y), SKBitmap > Gondwana.Drawing.Tilesheets.Tilesheet.GetAllBitmaps ( )

Collects the cached frame bitmaps indexed by their tile coordinates.

Returns
A dictionary of cached bitmaps keyed by frame coordinates. The tilesheet retains ownership of the bitmaps.

Definition at line 456 of file Tilesheet.cs.

◆ GetAllImages()

Dictionary<(string regionName, int x, int y), SKImage > Gondwana.Drawing.Tilesheets.Tilesheet.GetAllImages ( )

Collects the cached frame images indexed by their tile coordinates.

Returns
A dictionary of cached images keyed by frame coordinates. The tilesheet retains ownership of the images.

Definition at line 473 of file Tilesheet.cs.

◆ GetBitmap()

SKBitmap? Gondwana.Drawing.Tilesheets.Tilesheet.GetBitmap ( string regionName,
int x,
int y )

Gets the cached bitmap for the specified frame.

Parameters
regionNameThe name of the tilesheet region.
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.
Returns
The cached frame bitmap, or null if the frame is unavailable. The tilesheet retains ownership.

◆ GetFrame() [1/2]

Frame Gondwana.Drawing.Tilesheets.Tilesheet.GetFrame ( int x,
int y )

Creates a frame reference at the specified tile coordinates.

Parameters
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.
Returns
A frame reference to the requested region and tile coordinates.

◆ GetFrame() [2/2]

Frame Gondwana.Drawing.Tilesheets.Tilesheet.GetFrame ( string regionName,
int x,
int y )

Creates a frame reference at the specified tile coordinates.

Parameters
regionNameThe name of the tilesheet region.
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.
Returns
A frame reference to the requested region and tile coordinates.

◆ GetImage()

SKImage? Gondwana.Drawing.Tilesheets.Tilesheet.GetImage ( string regionName,
int x,
int y )

Gets the cached image for the specified frame.

Parameters
regionNameThe name of the tilesheet region.
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.
Returns
The cached frame image, or null if the frame is unavailable. The tilesheet retains ownership.

◆ GetRegion()

TilesheetRegion? Gondwana.Drawing.Tilesheets.Tilesheet.GetRegion ( string name)

Finds a tilesheet region by its case-insensitive name.

Parameters
nameThe name.
Returns
The matching region, or null if no region matches.

Definition at line 246 of file Tilesheet.cs.

◆ PersistImageToFile()

void Gondwana.Drawing.Tilesheets.Tilesheet.PersistImageToFile ( string imageFilePath,
SKEncodedImageFormat format = SKEncodedImageFormat::Png,
int quality = 100 )

Persists this tilesheet's source image to a file and promotes the tilesheet from a runtime-only bitmap to a file-backed tilesheet.

Parameters
imageFilePathThe destination image file path.
formatThe encoded image format.
qualityThe encoding quality from 0 through 100.

When masking or alpha premultiplication has transformed the runtime bitmap, the original source bitmap is persisted. The corresponding GTS metadata will reapply that transformation when the tilesheet is loaded.

Definition at line 390 of file Tilesheet.cs.

◆ RemoveRegion()

bool Gondwana.Drawing.Tilesheets.Tilesheet.RemoveRegion ( string name,
bool dispose = true )

Removes the named tilesheet region and optionally disposes it.

Parameters
nameThe name.
disposeWhether to dispose the removed resource.
Returns
true if the region was found and removed; otherwise, false.

Definition at line 266 of file Tilesheet.cs.

◆ ToByteArray()

byte[] Gondwana.Drawing.Tilesheets.Tilesheet.ToByteArray ( SKEncodedImageFormat format = SKEncodedImageFormat::Png,
int quality = 100 )

Encodes the tilesheet bitmap using the requested image format and quality.

Parameters
formatThe encoded image format.
qualityThe image encoding quality, from 0 through 100.
Returns
The encoded image bytes.

Definition at line 368 of file Tilesheet.cs.

Property Documentation

◆ AssetIdentifier

AssetsFileIdentifier? Gondwana.Drawing.Tilesheets.Tilesheet.AssetIdentifier
get

Gets the packed asset from which the image was loaded, if any.

Definition at line 180 of file Tilesheet.cs.

◆ DefaultRegion

TilesheetRegion Gondwana.Drawing.Tilesheets.Tilesheet.DefaultRegion
get

Gets the default tilesheet region.

Definition at line 172 of file Tilesheet.cs.

◆ ImageFilePath

string Gondwana.Drawing.Tilesheets.Tilesheet.ImageFilePath = string.Empty
get

Gets the loose source image path, when available.

Definition at line 184 of file Tilesheet.cs.

◆ MaskColor

SKColor? Gondwana.Drawing.Tilesheets.Tilesheet.MaskColor
get

Gets the color used for transparency masking.

Definition at line 188 of file Tilesheet.cs.

◆ MaskTolerance

byte Gondwana.Drawing.Tilesheets.Tilesheet.MaskTolerance = 5
get

Gets the per-channel tolerance used for transparency masking.

Definition at line 192 of file Tilesheet.cs.

◆ Name

string Gondwana.Drawing.Tilesheets.Tilesheet.Name = string.Empty
getset

Gets the name.

Definition at line 164 of file Tilesheet.cs.

◆ Premultiplied

bool Gondwana.Drawing.Tilesheets.Tilesheet.Premultiplied
get

Gets whether alpha premultiplication has been applied.

Definition at line 196 of file Tilesheet.cs.

◆ Regions

List<TilesheetRegion> Gondwana.Drawing.Tilesheets.Tilesheet.Regions = new()
get

Gets the named frame regions in the tilesheet.

Definition at line 168 of file Tilesheet.cs.

◆ SkBitmap

SKBitmap Gondwana.Drawing.Tilesheets.Tilesheet.SkBitmap = null!
get

Gets the current tilesheet bitmap used for rendering.

Definition at line 156 of file Tilesheet.cs.

◆ SkBitmapOriginal

SKBitmap? Gondwana.Drawing.Tilesheets.Tilesheet.SkBitmapOriginal
get

Gets the source bitmap retained before masking or alpha conversion.

Definition at line 160 of file Tilesheet.cs.

◆ this[int x, int y]

Frame Gondwana.Drawing.Tilesheets.Tilesheet.this[int x, int y]
get

Gets a frame reference at the specified tile coordinates.

Parameters
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.

Definition at line 510 of file Tilesheet.cs.

◆ this[string regionName, int x, int y]

Frame Gondwana.Drawing.Tilesheets.Tilesheet.this[string regionName, int x, int y]
get

Gets a frame reference at the specified tile coordinates.

Parameters
regionNameThe name of the tilesheet region.
xThe zero-based column in the tile grid.
yThe zero-based row in the tile grid.

Definition at line 502 of file Tilesheet.cs.

◆ this[string regionName]

TilesheetRegion Gondwana.Drawing.Tilesheets.Tilesheet.this[string regionName]
get

Gets the named tilesheet region.

Parameters
regionNameThe name of the tilesheet region.

Definition at line 490 of file Tilesheet.cs.

◆ ValueBag

TypedValueBag Gondwana.Drawing.Tilesheets.Tilesheet.ValueBag = new()
getset

Gets or sets the custom typed values associated with this object.

Definition at line 176 of file Tilesheet.cs.

Event Documentation

◆ Disposed

Action<Tilesheet>? Gondwana.Drawing.Tilesheets.Tilesheet.Disposed

Occurs after the object releases its resources.

Definition at line 38 of file Tilesheet.cs.