Cauldron3D.Frame (Cauldron3D v0.2.2)

Copy Markdown View Source

A rendered picture, rows top to bottom: indexed colour, one byte per pixel, or RGBA, four.

frame = Cauldron3D.Render.draw(view, polygons)
Cauldron3D.Frame.rgba(frame, palette)

Summary

Functions

overlay drawn over frame with its top left at {x, y}, its pixels of colour clear left out; the parts outside the frame are cut off. A Cauldron3D.Texture serves as an overlay too. On an RGBA frame the overlay is RGBA too, laid over by its alpha, and clear is not used.

A frame of one colour.

The frame as RGB bytes: an indexed frame through palette.

The frame as RGBA bytes: an indexed frame through palette, 768 bytes of red, green and blue.

The frame scaled to {width, height} by taking the nearest pixel.

Types

t()

@type t() :: %Cauldron3D.Frame{
  format: :indexed | :rgba,
  height: pos_integer(),
  pixels: binary(),
  width: pos_integer()
}

Functions

blit(frame, overlay, at, clear \\ nil)

@spec blit(t(), t() | Cauldron3D.Texture.t(), {integer(), integer()}, byte() | nil) ::
  t()

overlay drawn over frame with its top left at {x, y}, its pixels of colour clear left out; the parts outside the frame are cut off. A Cauldron3D.Texture serves as an overlay too. On an RGBA frame the overlay is RGBA too, laid over by its alpha, and clear is not used.

new(width, height, colour \\ 0)

@spec new(pos_integer(), pos_integer(), byte()) :: t()

A frame of one colour.

rgb(frame, palette)

@spec rgb(t(), binary() | nil) :: binary()

The frame as RGB bytes: an indexed frame through palette.

rgba(frame, palette)

@spec rgba(t(), binary() | nil) :: binary()

The frame as RGBA bytes: an indexed frame through palette, 768 bytes of red, green and blue.

scale(map, width, height)

@spec scale(t() | Cauldron3D.Texture.t(), pos_integer(), pos_integer()) :: t()

The frame scaled to {width, height} by taking the nearest pixel.