Cauldron3D.Formats.Spr (Cauldron3D.Formats v0.2.2)

Copy Markdown View Source

A sprite, .spr: flat pictures that face the viewer, Quake's (version 1) or Half-Life's (version 2, with its own palette and a format for how it is drawn).

{:ok, sprite} = Cauldron3D.Formats.Spr.parse(bytes)

frames is a tuple of {:single, picture} or {:group, [{picture, until}]}, each picture %{texture: Cauldron3D.Texture.t(), origin: {x, y}}, the origin being the pixel that sits on the entity. Colour 255 is see-through.

Summary

Functions

The sprite in data.

The picture of frame number frame at time seconds.

Every frame's picture, groups opened up, in order.

A frame's picture as an RGBA texture by the sprite's format: :normal and :additive opaque, :alpha_test see-through at colour 255, :index_alpha the palette's last colour with each pixel's index as its alpha.

Types

t()

@type t() :: %Cauldron3D.Formats.Spr{
  format: term(),
  frames: term(),
  kind: term(),
  maxs: term(),
  mins: term()
}

Functions

parse(arg1)

@spec parse(binary()) :: {:ok, t()} | {:error, :not_a_sprite}

The sprite in data.

picture(spr, frame, time)

@spec picture(t(), integer(), number()) :: map()

The picture of frame number frame at time seconds.

pictures(spr)

@spec pictures(t()) :: [map()]

Every frame's picture, groups opened up, in order.

rgba(spr, texture, palette \\ nil)

@spec rgba(t(), Cauldron3D.Texture.t(), binary() | nil) :: Cauldron3D.Texture.t()

A frame's picture as an RGBA texture by the sprite's format: :normal and :additive opaque, :alpha_test see-through at colour 255, :index_alpha the palette's last colour with each pixel's index as its alpha.