Cauldron2D.GameMaker.Pictures (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

The pictures of a game, cut from its decoded texture pages as FrenchCurve.Rasters.

{:ok, data} = Cauldron2D.GameMaker.Data.read("data.win")
{:ok, pictures} = Cauldron2D.GameMaker.Pictures.new(data)

frames = Cauldron2D.GameMaker.Pictures.sprite(pictures, Enum.at(data.sprites, 3))
tile = Cauldron2D.GameMaker.Pictures.tile(pictures, Enum.at(data.backgrounds, 0), 17)

new/1 decodes every page once; a Pictures holds them as RGBA and every cut after that is binary slicing. A region is returned at its full bounds, its trimmed margins put back as see-through pixels, so a sprite frame is always the sprite's size and its origin applies unchanged.

Summary

Functions

The whole picture of background, nil for a background with none.

The picture of font's glyph for the code point character, nil when it has none.

Every texture page of data, decoded.

The picture region describes, at its full bounds.

Every frame of sprite, in order.

The rectangle {x, y, width, height} of sprite's first frame that a tile on a GameMaker Studio 2 asset layer names, see-through outside the frame.

Every picture Cauldron2D.GameMaker.Draw names, cut once, keyed as it names them: each sprite frame, each background, each tile of each tileset, each rectangle a room's placed tiles cut from a background or a sprite (rectangles with no area are left out), each glyph of each font as {:glyph, font, character}, and :pixel. Pass &Map.get(table, &1) to Cauldron2D.DrawList.render/4.

Tile id of the tileset background, or the rectangle {x, y, width, height} of its picture that a GameMaker Studio 1 room's tile names. The tile is always its full size: the part of the rectangle outside the picture is see-through.

Types

page()

@type page() :: {pos_integer(), pos_integer(), binary()}

t()

@type t() :: %Cauldron2D.GameMaker.Pictures{pages: tuple()}

Functions

background(pictures, background)

@spec background(t(), Cauldron2D.GameMaker.Background.t()) ::
  FrenchCurve.Raster.t() | nil

The whole picture of background, nil for a background with none.

glyph(pictures, font, character)

The picture of font's glyph for the code point character, nil when it has none.

new(data)

@spec new(Cauldron2D.GameMaker.Data.t()) :: {:ok, t()} | {:error, term()}

Every texture page of data, decoded.

region(pictures, region)

The picture region describes, at its full bounds.

sprite(pictures, sprite)

Every frame of sprite, in order.

sprite_part(pictures, sprite, rectangle)

The rectangle {x, y, width, height} of sprite's first frame that a tile on a GameMaker Studio 2 asset layer names, see-through outside the frame.

table(pictures, data)

@spec table(t(), Cauldron2D.GameMaker.Data.t()) :: %{
  required(term()) => FrenchCurve.Raster.t()
}

Every picture Cauldron2D.GameMaker.Draw names, cut once, keyed as it names them: each sprite frame, each background, each tile of each tileset, each rectangle a room's placed tiles cut from a background or a sprite (rectangles with no area are left out), each glyph of each font as {:glyph, font, character}, and :pixel. Pass &Map.get(table, &1) to Cauldron2D.DrawList.render/4.

tile(pictures, background, id)

Tile id of the tileset background, or the rectangle {x, y, width, height} of its picture that a GameMaker Studio 1 room's tile names. The tile is always its full size: the part of the rectangle outside the picture is see-through.