Table of Contents

Class SpritePackOptions

Namespace
Egami
Assembly
Egami.dll
public sealed record SpritePackOptions : IEquatable<SpritePackOptions>
Inheritance
SpritePackOptions
Implements
Inherited Members

Examples

// Pack sprites with a 2-pixel gap and 1 pixel of extruded edge, so GPU filtering never bleeds between them.
using SpriteSheet sheet = SpriteSheet.Pack([small, tiny, small, tiny], new SpritePackOptions { Padding = 2, Extrude = 1, PowerOfTwo = true });
sheet.Image.Save("sprites.png");

// The rectangles are plain data: writing them for a game engine is one line of System.Text.Json.
File.WriteAllText("sprites.json", JsonSerializer.Serialize(sheet.Frames.Select(f => new { f.X, f.Y, w = f.Width, h = f.Height })));

Properties

Extrude

Gets how many pixels each sprite's edge pixels are copied outward, so a GPU's filtering at the sprite's border reads the sprite's own colors instead of its neighbour's. Defaults to 0.

public int Extrude { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is negative.

MaxWidth

Gets the widest the sheet may be, in pixels; sprites wider than this throw. Defaults to 4,096, a safe GPU texture size.

public int MaxWidth { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is less than 1.

Padding

Gets the transparent gap between sprites, in pixels. Defaults to 0.

public int Padding { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is negative.

PowerOfTwo

Gets a value indicating whether the sheet's width and height are rounded up to powers of two. Defaults to false.

public bool PowerOfTwo { get; init; }

Property Value

bool

Trim

Gets a value indicating whether each sprite's fully transparent border is trimmed away before packing; Offsets then says where the trimmed sprite sat in its original. Defaults to false.

public bool Trim { get; init; }

Property Value

bool