![]() |
Gondwana Game Engine
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, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
|
Represents a tilesheet image and metadata for rendering tiles. More...
Public Member Functions | |
| Tilesheet (string name, SKBitmap bitmap) | |
| Initializes a new instance of the Tilesheet class with the specified name and bitmap. | |
| Tilesheet (string name, Stream stream) | |
| Initializes a new instance of the Tilesheet class by loading an image from a stream. | |
| Tilesheet (string name, string file) | |
| Initializes a new instance of the Tilesheet class by loading an image from a file. | |
| Tilesheet (AssetsFile resFile, string entryName) | |
| Initializes a new instance of the Tilesheet class by loading an image from an assets file. | |
| Tilesheet (Tilesheet baseSheet, string name, string file) | |
| Initializes a new instance of the Tilesheet class by copying settings from a base tilesheet and loading a new image from a file. | |
| void | ApplyMask (SKColor? maskColor=null, byte tolerance=5) |
| Applies an alpha mask to the tilesheet, making pixels matching the specified color transparent, and then premultiplies the alpha channel. | |
| void | ApplyPremultiplyAlpha () |
| Premultiplies the alpha channel of the bitmap, improving rendering performance and quality. Preserves the original bitmap in SkBitmapOriginal before applying the operation. | |
| byte[] | ToByteArray (SKEncodedImageFormat format=SKEncodedImageFormat.Png, int quality=100) |
| Encodes the tilesheet bitmap to a byte array in the specified image format. | |
| SKImage? | GetImage (int x, int y) |
| Retrieves the SkiaSharp image for the tile at the specified coordinates. | |
| SKBitmap? | GetBitmap (int x, int y) |
| Retrieves the SkiaSharp bitmap for the tile at the specified coordinates. | |
| Dictionary<(int x, int y), SKBitmap > | GetAllBitmaps () |
| Retrieves all tile bitmaps from the tilesheet as a dictionary indexed by their coordinates. | |
| Dictionary<(int x, int y), SKImage > | GetAllImages () |
| Retrieves all tile images from the tilesheet as a dictionary indexed by their coordinates. | |
| void | Dispose () |
| Releases all resources used by this tilesheet, including cached tiles, bitmaps, and registration in the TilesheetRegistry. | |
Properties | |
| SKBitmap | SkBitmap [get] |
| Gets the SkiaSharp bitmap containing the tilesheet image. This may be a modified version if alpha masking or premultiplication has been applied. | |
| SKBitmap? | SkBitmapOriginal = null [get] |
Gets the original SkiaSharp bitmap before any alpha masking or premultiplication was applied. Returns null if no modifications have been made. | |
| string | Name [get, set] |
| Gets or sets the name of this tilesheet. Changing the name updates the tilesheet's registration in the TilesheetRegistry. | |
| Size | TileSize [get, set] |
| Gets or sets the size of each individual tile in the tilesheet (without overhang). Setting this property rebuilds the internal tile cache. | |
| Overhang | OverhangPixels = Overhang.None [get, set] |
| Gets or sets the overhang dimensions (in pixels) that extend beyond each tile's base boundaries. | |
| int | InitialOffsetX [get, set] |
| Gets or sets the horizontal offset (in pixels) from the left edge of the tilesheet to the first tile. Setting this property rebuilds the internal tile cache. | |
| int | InitialOffsetY [get, set] |
| Gets or sets the vertical offset (in pixels) from the top edge of the tilesheet to the first tile. Setting this property rebuilds the internal tile cache. | |
| int | XPixelsBetweenTiles [get, set] |
| Gets or sets the horizontal spacing (in pixels) between tiles in the tilesheet. Setting this property rebuilds the internal tile cache. | |
| int | YPixelsBetweenTiles [get, set] |
| Gets or sets the vertical spacing (in pixels) between tiles in the tilesheet. Setting this property rebuilds the internal tile cache. | |
| TypedValueBag | ValueBag = new() [get, set] |
| Gets or sets the value bag for storing arbitrary typed values associated with this tilesheet. | |
| AssetsFileIdentifier? | AssetIdentifier [get] |
Gets the asset identifier if this tilesheet was loaded from an assets file. Returns null if the tilesheet was loaded from another source. | |
| string | ImageFilePath = string.Empty [get] |
| Gets the file path of the image file if this tilesheet was loaded from a file. Returns an empty string if the tilesheet was loaded from another source. | |
| SKColor? | MaskColor = null [get] |
Gets the color used for alpha masking, if ApplyMask has been called. Returns null if no mask has been applied. | |
| byte | MaskTolerance = 5 [get] |
| Gets the tolerance value used when applying the alpha mask. This determines how closely pixels must match the mask color to be made transparent. | |
| bool | Premultiplied = false [get] |
Gets a value indicating whether the bitmap has been premultiplied with its alpha channel. This is true after calling ApplyMask or ApplyPremultiplyAlpha. | |
| Frame | this[int x, int y] [get] |
| Returns a Frame representing the tile at the given sheet coordinates. | |
Events | |
| EventHandler< TilesheetDisposedEventArgs > | Disposed |
| Occurs when this tilesheet is disposed. | |
Represents a tilesheet image and metadata for rendering tiles.
| Gondwana.Drawing.Tilesheets.Tilesheet.Tilesheet | ( | string | name, |
| SKBitmap | bitmap ) |
| Gondwana.Drawing.Tilesheets.Tilesheet.Tilesheet | ( | string | name, |
| Stream | stream ) |
Initializes a new instance of the Tilesheet class by loading an image from a stream.
| name | The name to assign to this tilesheet. |
| stream | The stream containing the image data. |
| ArgumentException | Thrown when the stream contains invalid image data. |
| Gondwana.Drawing.Tilesheets.Tilesheet.Tilesheet | ( | string | name, |
| string | file ) |
Initializes a new instance of the Tilesheet class by loading an image from a file.
| name | The name to assign to this tilesheet. |
| file | The path to the image file. |
| ArgumentException | Thrown when the file is not a valid image. |
| Gondwana.Drawing.Tilesheets.Tilesheet.Tilesheet | ( | AssetsFile | resFile, |
| string | entryName ) |
Initializes a new instance of the Tilesheet class by loading an image from an assets file.
| resFile | The assets file containing the tilesheet image. |
| entryName | The name of the asset entry within the assets file. |
| ArgumentNullException | Thrown when resFile is null. |
| ArgumentException | Thrown when entryName is null or whitespace, or when the asset cannot be decoded. |
| InvalidOperationException | Thrown when the asset entry does not exist or returns a null data stream. |
| Gondwana.Drawing.Tilesheets.Tilesheet.Tilesheet | ( | Tilesheet | baseSheet, |
| string | name, | ||
| string | file ) |
Initializes a new instance of the Tilesheet class by copying settings from a base tilesheet and loading a new image from a file.
| baseSheet | The tilesheet whose settings should be copied. |
| name | The name to assign to this tilesheet. |
| file | The path to the image file. |
| void Gondwana.Drawing.Tilesheets.Tilesheet.ApplyMask | ( | SKColor? | maskColor = null, |
| byte | tolerance = 5 ) |
Applies an alpha mask to the tilesheet, making pixels matching the specified color transparent, and then premultiplies the alpha channel.
| maskColor | The color to treat as transparent. If null, defaults to white. |
| tolerance | The tolerance for color matching (0-255). Lower values require closer matches. |
| ArgumentException | Thrown when the bitmap is null or empty. |
| void Gondwana.Drawing.Tilesheets.Tilesheet.ApplyPremultiplyAlpha | ( | ) |
Premultiplies the alpha channel of the bitmap, improving rendering performance and quality. Preserves the original bitmap in SkBitmapOriginal before applying the operation.
| ArgumentException | Thrown when the bitmap is null or empty. |
| void Gondwana.Drawing.Tilesheets.Tilesheet.Dispose | ( | ) |
Releases all resources used by this tilesheet, including cached tiles, bitmaps, and registration in the TilesheetRegistry.
| Dictionary<(int x, int y), SKBitmap > Gondwana.Drawing.Tilesheets.Tilesheet.GetAllBitmaps | ( | ) |
Retrieves all tile bitmaps from the tilesheet as a dictionary indexed by their coordinates.
| Dictionary<(int x, int y), SKImage > Gondwana.Drawing.Tilesheets.Tilesheet.GetAllImages | ( | ) |
Retrieves all tile images from the tilesheet as a dictionary indexed by their coordinates.
| SKBitmap? Gondwana.Drawing.Tilesheets.Tilesheet.GetBitmap | ( | int | x, |
| int | y ) |
Retrieves the SkiaSharp bitmap for the tile at the specified coordinates.
| x | The zero-based tile column index. |
| y | The zero-based tile row index. |
null if the coordinates are out of bounds or the tile cache is not initialized. | SKImage? Gondwana.Drawing.Tilesheets.Tilesheet.GetImage | ( | int | x, |
| int | y ) |
Retrieves the SkiaSharp image for the tile at the specified coordinates.
| x | The zero-based tile column index. |
| y | The zero-based tile row index. |
null if the coordinates are out of bounds or the tile cache is not initialized. | byte[] Gondwana.Drawing.Tilesheets.Tilesheet.ToByteArray | ( | SKEncodedImageFormat | format = SKEncodedImageFormat::Png, |
| int | quality = 100 ) |
Encodes the tilesheet bitmap to a byte array in the specified image format.
| format | The image format to encode to. Defaults to PNG. |
| quality | The encoding quality (0-100). Defaults to 100 (highest quality). |
| ArgumentException | Thrown when the bitmap is null or empty. |
|
get |
Gets the asset identifier if this tilesheet was loaded from an assets file. Returns null if the tilesheet was loaded from another source.
|
get |
Gets the file path of the image file if this tilesheet was loaded from a file. Returns an empty string if the tilesheet was loaded from another source.
|
getset |
Gets or sets the horizontal offset (in pixels) from the left edge of the tilesheet to the first tile. Setting this property rebuilds the internal tile cache.
|
getset |
Gets or sets the vertical offset (in pixels) from the top edge of the tilesheet to the first tile. Setting this property rebuilds the internal tile cache.
|
get |
Gets the color used for alpha masking, if ApplyMask has been called. Returns null if no mask has been applied.
|
get |
Gets the tolerance value used when applying the alpha mask. This determines how closely pixels must match the mask color to be made transparent.
|
getset |
Gets or sets the name of this tilesheet. Changing the name updates the tilesheet's registration in the TilesheetRegistry.
|
getset |
Gets or sets the overhang dimensions (in pixels) that extend beyond each tile's base boundaries.
|
get |
Gets a value indicating whether the bitmap has been premultiplied with its alpha channel. This is true after calling ApplyMask or ApplyPremultiplyAlpha.
|
get |
Gets the SkiaSharp bitmap containing the tilesheet image. This may be a modified version if alpha masking or premultiplication has been applied.
|
get |
Gets the original SkiaSharp bitmap before any alpha masking or premultiplication was applied. Returns null if no modifications have been made.
|
get |
Returns a Frame representing the tile at the given sheet coordinates.
| x | Zero-based tile column index. |
| y | Zero-based tile row index. |
|
getset |
Gets or sets the size of each individual tile in the tilesheet (without overhang). Setting this property rebuilds the internal tile cache.
|
getset |
Gets or sets the value bag for storing arbitrary typed values associated with this tilesheet.
|
getset |
Gets or sets the horizontal spacing (in pixels) between tiles in the tilesheet. Setting this property rebuilds the internal tile cache.
|
getset |
Gets or sets the vertical spacing (in pixels) between tiles in the tilesheet. Setting this property rebuilds the internal tile cache.
| EventHandler<TilesheetDisposedEventArgs> Gondwana.Drawing.Tilesheets.Tilesheet.Disposed |
Occurs when this tilesheet is disposed.