Cauldron2D.Projection.Volume.Native (Cauldron2D v0.2.2)

Copy Markdown View Source

The per-pixel half of Cauldron2D.Projection.Volume, in C.

tint/6 takes a rectangle of pixels, the rays that look through it and one volume, and gives the rectangle back with the volume's colour blended in. It understands the shapes of Cauldron2D.Projection.Volume.Shapes and nothing else; a volume with a shape module of its own is drawn in Elixir.

available?/0 says whether the library built and loaded. Where it did not, Volume draws every volume in Elixir and answers the same picture some fifteen times slower.

Summary

Functions

Whether the library is loaded and volumes are drawn in C.

pixels, a width by height rectangle of RGBA, with volume blended in.

Functions

available?()

@spec available?() :: boolean()

Whether the library is loaded and volumes are drawn in C.

tint(pixels, width, height, plan, limits, volume)

@spec tint(binary(), pos_integer(), pos_integer(), tuple(), binary(), tuple()) ::
  binary()

pixels, a width by height rectangle of RGBA, with volume blended in.

plan is {origin, origin_x, origin_y, direction, direction_x, direction_y}, each a triple, giving the ray through the rectangle's pixel {column, row} as origin + column * origin_x + row * origin_y looking along direction + column * direction_x + row * direction_y.

limits is one native float per pixel, how far that pixel can see before something opaque stops it, or an empty binary for no limit.

volume is {kind, falloff, {x, y}, {red, green, blue}, {strength, density, thickness}, params, cells}, where params is the shape's numbers as native doubles and cells is nil or {x, y, width, height, bits}, one byte per tile.