Cauldron3D.Paint (Cauldron3D v0.2.2)

Copy Markdown View Source

How a polygon's pixels get their colours.

  • {:flat, colour} — one colour
  • {:texture, texture, light} — a Cauldron3D.Texture repeated across the polygon by its uvs, through the light table at light (0 to 255, 128 the texture's own colours), or as it is when light is nil
  • {:shaded, texture} — as :texture, the light carried across from the polygon's lights
  • {:surface, texture} — a texture already lit, its edge pixels repeated beyond it
  • {:warp, texture, opts} — a texture rippling as liquid does: each place on it moved by :amplitude pixels (default 8.0) along a sine of the other axis, of :wavelength pixels (default 128.0), moving with :time seconds at :speed (default 1.0) turns a second; :light as :texture's, default nil
  • {:sky, layers, opts} — a sky at no distance: layers is a list of {texture, speed}, nearest first, each drawn where the one before is colour :clear (default 0) and moving speed pixels a second with :time; :scale (default 378.0) is how far across the sky a view straight ahead reaches, and :flatten (default 3.0) squashes it toward the horizon
  • {:fun, fun} — fun.(first, stop, y, setup, context) returns the stop - first colours of the run itself

The context is a map: :light_table (rows of 256 colours, brightest first), :light_rows (how many rows it has), :background (the colour behind every polygon), and :view, which {:sky, ...} reads. Light value v uses row (255 - v) * light_rows / 256, held inside the table.

Summary

Functions

The light table row for light value light (0 to 255, brighter higher).

The colours of pixels first up to stop of row y, as a binary: a byte a pixel, or in a full-colour picture (a context with :rgba) four, as Cauldron3D.Paint.Rgba paints them.

Types

context()

@type context() :: %{optional(atom()) => term()}

Functions

light_row(light, context)

@spec light_row(number(), context()) :: non_neg_integer()

The light table row for light value light (0 to 255, brighter higher).

span(paint, setup, first, stop, y, context)

@spec span(term(), Cauldron3D.Setup.t(), integer(), integer(), integer(), context()) ::
  binary()

The colours of pixels first up to stop of row y, as a binary: a byte a pixel, or in a full-colour picture (a context with :rgba) four, as Cauldron3D.Paint.Rgba paints them.