Cauldron3D.Paint.Spans (Cauldron3D v0.2.2)

Copy Markdown View Source

The RGBA pixels of one row's run of a textured polygon, for Cauldron3D.Paint.Rgba.

planes = {w0, wx, uw0, uwx, vw0, vwx}
Cauldron3D.Paint.Spans.texture({pixels, 64, 64, colours}, nil, nil, planes, {10, 90})

A texture is {pixels, width, height, colours}, and a run {first, stop}, the pixels from first up to stop. planes is a row's {w, uw, vw} planes as {at_x_zero, per_x} pairs, flattened; the texel at pixel x is at floor(uw / w), floor(vw / w) taken at x + 0.5. colours is the texture's Cauldron3D.Texture.colours/1 table for an indexed texture, or nil for an RGBA one.

available?/0 says whether the C library loaded. Where it did not the same bytes are made in Elixir.

Summary

Functions

Whether the library is loaded and spans are filled in C.

Pixels first up to stop of a texture whose edge pixels repeat beyond it.

Pixels first up to stop of a texture repeated both ways. A texel of index clear in an indexed texture is <<0, 0, 0, 0>>. light multiplies red, green and blue: a scale, one scale a channel, {:plane, origin, per_x} for the scale (origin + per_x * (x + 0.5)) / 128 at pixel x, or nil for none.

base, RGBA pixels from column first, each channel multiplied by its tint plane over w: planes is {w0, wx, r0, rx, g0, gx, b0, bx, a0, ax}, each taken at x + 0.5. A pixel whose alpha is below threshold is <<0, 0, 0, 0>>.

Types

light()

@type light() ::
  nil | number() | {number(), number(), number()} | {:plane, number(), number()}

planes()

@type planes() :: {number(), number(), number(), number(), number(), number()}

run()

@type run() :: {integer(), integer()}

source()

@type source() :: {binary(), pos_integer(), pos_integer(), binary() | nil}

Functions

available?()

@spec available?() :: boolean()

Whether the library is loaded and spans are filled in C.

surface(arg1, planes, arg2)

@spec surface(source(), planes(), run()) :: binary()

Pixels first up to stop of a texture whose edge pixels repeat beyond it.

texture(arg1, clear, light, planes, arg2)

@spec texture(source(), byte() | nil, light(), planes(), run()) :: binary()

Pixels first up to stop of a texture repeated both ways. A texel of index clear in an indexed texture is <<0, 0, 0, 0>>. light multiplies red, green and blue: a scale, one scale a channel, {:plane, origin, per_x} for the scale (origin + per_x * (x + 0.5)) / 128 at pixel x, or nil for none.

tint(base, first, arg, threshold)

@spec tint(binary(), integer(), tuple(), number()) :: binary()

base, RGBA pixels from column first, each channel multiplied by its tint plane over w: planes is {w0, wx, r0, rx, g0, gx, b0, bx, a0, ax}, each taken at x + 0.5. A pixel whose alpha is below threshold is <<0, 0, 0, 0>>.