Cauldron2D.Net.Sheet (Cauldron2D.Net v0.1.3)

Copy Markdown View Source

A Cauldron2D.Atlas as one PNG sprite sheet and an index a browser draws from, packed by Cauldron2D.Sheet.

sheet = Cauldron2D.Net.Sheet.build(atlas)
Cauldron2D.Net.Sheet.index(sheet, "/atlas.png")

cached/1 keeps the sheet of an installed atlas and rebuilds it when a different atlas is installed under the name.

Summary

Functions

Lay every art of atlas out on one sheet.

The sheet for the installed atlas name, built on first use and again when the atlas changes.

The sheet's pixel size.

What a client needs to draw from the sheet at url, as Cauldron2D.Sheet.index/2 gives it.

Types

t()

@type t() :: %{
  tile: pos_integer(),
  arts: %{required(term()) => pos_integer()},
  frames: [[non_neg_integer()]],
  anim: %{
    required(pos_integer()) => %{indices: [pos_integer()], fps: pos_integer()}
  },
  png: binary(),
  columns: pos_integer(),
  rows: pos_integer(),
  void: String.t()
}

Functions

build(atlas)

@spec build(Cauldron2D.Atlas.t() | Cauldron2D.Atlas.name()) :: t()

Lay every art of atlas out on one sheet.

cached(name)

@spec cached(Cauldron2D.Atlas.name()) :: t()

The sheet for the installed atlas name, built on first use and again when the atlas changes.

dimensions(sheet)

@spec dimensions(t()) :: {pos_integer(), pos_integer()}

The sheet's pixel size.

index(sheet, url)

@spec index(t(), String.t()) :: map()

What a client needs to draw from the sheet at url, as Cauldron2D.Sheet.index/2 gives it.