CauldronGPU.Sectors.Live.Pictures (CauldronGPU v0.3.3)

Copy Markdown View Source

Pictures of a Cauldron2D.Sectors.Pictures set uploaded on first use, each through a light table: table nil shows the palette's own colours, table n each colour index first mapped through the set's table n (as a fixed light table draws it). Textures and materials are kept by {picture, table} and made once.

pictures = CauldronGPU.Sectors.Live.Pictures.new(set, palette)
{%{handle: handle, masked: false}, pictures} = CauldronGPU.Sectors.Live.Pictures.texture(pictures, target, 7, nil)
{material, pictures} = CauldronGPU.Sectors.Live.Pictures.material(pictures, target, {:wall, 7, nil}, fn texture -> %CauldronGPU.Material{base_texture: texture.handle} end)

The set must keep its pictures in Elixir (Pictures.new(named, tables, native: false)); palette is 768 bytes.

Summary

Functions

The palette's colours through light table table (nil for none), as a tuple of 256 RGBA binaries.

Every handle uploaded.

The material kept as key, made the first time from make, given the texture of key's picture through its table: key is a tuple whose second and third elements are the picture and the table.

No pictures uploaded yet from set, coloured by palette.

The texture of picture through light table table, uploaded through target the first time.

Types

t()

@type t() :: %CauldronGPU.Sectors.Live.Pictures{
  colours: %{required(non_neg_integer() | nil) => tuple()},
  materials: %{required(term()) => CauldronGPU.Handle.t()},
  palette: binary(),
  set: Cauldron2D.Sectors.Pictures.t(),
  textures: %{
    required({non_neg_integer(), non_neg_integer() | nil}) => texture()
  }
}

texture()

@type texture() :: %{handle: CauldronGPU.Handle.t(), masked: boolean()}

Functions

colours(pictures, table)

@spec colours(t(), non_neg_integer() | nil) :: {tuple(), t()}

The palette's colours through light table table (nil for none), as a tuple of 256 RGBA binaries.

handles(pictures)

@spec handles(t()) :: [CauldronGPU.Handle.t()]

Every handle uploaded.

material(pictures, target, key, make)

@spec material(t(), CauldronGPU.Target.t(), tuple(), (texture() ->
                                                  CauldronGPU.Material.t())) ::
  {CauldronGPU.Handle.t(), t()}

The material kept as key, made the first time from make, given the texture of key's picture through its table: key is a tuple whose second and third elements are the picture and the table.

new(set, palette)

@spec new(Cauldron2D.Sectors.Pictures.t(), binary()) :: t()

No pictures uploaded yet from set, coloured by palette.

texture(pictures, target, picture, table)

@spec texture(t(), CauldronGPU.Target.t(), non_neg_integer(), non_neg_integer() | nil) ::
  {texture(), t()}

The texture of picture through light table table, uploaded through target the first time.