Cauldron2D.GameMaker.Texture (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A texture page (a TXTR entry): one packed image that sprites, tilesets and fonts cut their pictures from through Cauldron2D.GameMaker.Region.

encoding names how the page's bytes are stored: :png, :qoi (GameMaker's QOI variant), or :bz2_qoi (that, compressed with bzip2). bytes is the page as stored. decode/1 turns a PNG page into a FrenchCurve.Raster; the other two encodings return {:error, {:unsupported_encoding, encoding}}.

Summary

Functions

The page as a raster.

Every texture page in the TXTR chunk at at, size bytes long, in order. A PNG page ends at its IEND; a page in another encoding runs to the next page's bytes or the chunk's end.

Types

encoding()

@type encoding() :: :png | :qoi | :bz2_qoi

t()

@type t() :: %Cauldron2D.GameMaker.Texture{bytes: binary(), encoding: encoding()}

Functions

decode(texture)

@spec decode(t()) :: {:ok, FrenchCurve.Raster.t()} | {:error, term()}

The page as a raster.

read_all(data, at, size)

@spec read_all(binary(), non_neg_integer(), non_neg_integer()) :: [t()]

Every texture page in the TXTR chunk at at, size bytes long, in order. A PNG page ends at its IEND; a page in another encoding runs to the next page's bytes or the chunk's end.