Cauldron2D.Parallax.Bands (Cauldron2D v0.2.2)

Copy Markdown View Source

Horizontal bands of one layer, each scrolling at its own factor.

bands = Cauldron2D.Parallax.Bands.new([{0..5, 0.1}, {6..11, 0.45}, {12..23, 0.9}])
Cauldron2D.Parallax.Bands.roll(raster, bands, {focus_x, focus_y}, tile)

Ranges are tile rows from the top of the picture, read in order, the first range holding a row deciding it. A row no range covers does not move. A band reads the focus itself, so a layer that carries bands wants a factor of 0.0 on the axis they move along.

Summary

Functions

The factor for tile row row, or 0.0 where no band covers it.

Bands from [{tile_rows, factor}].

raster with every band's pixel rows rolled sideways by its own share of focus.

Types

t()

@type t() :: %Cauldron2D.Parallax.Bands{ranges: [{Range.t(), float()}]}

Functions

factor(bands, row)

@spec factor(t(), integer()) :: float()

The factor for tile row row, or 0.0 where no band covers it.

new(ranges)

@spec new([{Range.t(), number()}]) :: t()

Bands from [{tile_rows, factor}].

roll(raster, bands, arg3, tile)

@spec roll(FrenchCurve.Raster.t(), t() | nil, {number(), number()}, pos_integer()) ::
  FrenchCurve.Raster.t()

raster with every band's pixel rows rolled sideways by its own share of focus.