Cauldron2D.Wx.Painter (Cauldron2D.Wx v0.1.3)

Copy Markdown View Source

Where everything goes on a canvas: the map's tiles around the focus and the movers, as sheet indices at pixel positions, for a frame and map in the shapes Cauldron2D.Net.Wire gives.

Cauldron2D.Wx.Painter.blits(frame, map, {width, height}, scale)

The focus sits at the centre of the canvas, at a map's edge and past it alike; a map that wraps repeats around it. scale is the pixel size of a tile.

Summary

Functions

Every tile and mover in view, bottom to top, as {index, x, y} in pixels.

The tiles in view whose index is one of indices, as {index, x, y} in pixels: the cells a layer left out.

Where a label at world position at lands on the canvas, in pixels: once, or on every copy in view of a wrapping map.

Every tile of the map once, as {index, x, y} in pixels from the map's top-left corner: what a layer of the whole map is drawn from. except: is a set of indices to leave out, for cells drawn every frame instead.

Where a layer of the whole map goes on the canvas for frame: one pixel offset, or every copy in view of a wrapping map.

The movers in view, as {index, x, y} in pixels.

The world position at the canvas's top-left corner.

The world position under a canvas point.

The focus that keeps the world under canvas point {cx, cy} there when the tile goes from from to to pixels.

Types

blit()

@type blit() :: {non_neg_integer(), integer(), integer()}

frame()

@type frame() :: %{
  focus: {number(), number()},
  movers: [{non_neg_integer(), number(), number()}]
}

map_layer()

@type map_layer() :: %{
  width: pos_integer(),
  height: pos_integer(),
  wrap: boolean(),
  rows: [[non_neg_integer()]]
}

Functions

blits(frame, map, size, scale)

@spec blits(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) :: [
  blit()
]

Every tile and mover in view, bottom to top, as {index, x, y} in pixels.

cell_blits(frame, map, size, scale, indices)

@spec cell_blits(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  MapSet.t()
) :: [
  blit()
]

The tiles in view whose index is one of indices, as {index, x, y} in pixels: the cells a layer left out.

label_blits(frame, map, size, scale, arg)

@spec label_blits(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  {number(), number()}
) :: [{integer(), integer()}]

Where a label at world position at lands on the canvas, in pixels: once, or on every copy in view of a wrapping map.

layer_blits(map, scale, opts \\ [])

@spec layer_blits(map_layer(), pos_integer(), keyword()) :: [blit()]

Every tile of the map once, as {index, x, y} in pixels from the map's top-left corner: what a layer of the whole map is drawn from. except: is a set of indices to leave out, for cells drawn every frame instead.

layer_offsets(frame, map, size, scale)

@spec layer_offsets(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer()
) :: [
  {integer(), integer()}
]

Where a layer of the whole map goes on the canvas for frame: one pixel offset, or every copy in view of a wrapping map.

mover_blits(frame, map, size, scale)

@spec mover_blits(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) ::
  [blit()]

The movers in view, as {index, x, y} in pixels.

origin(map, map, arg, scale)

@spec origin(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) ::
  {float(), float()}

The world position at the canvas's top-left corner.

world_at(frame, map, size, scale, arg)

@spec world_at(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  {number(), number()}
) :: {float(), float()}

The world position under a canvas point.

zoom_about(frame, map, size, from, to, arg)

@spec zoom_about(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  pos_integer(),
  {number(), number()}
) :: {float(), float()}

The focus that keeps the world under canvas point {cx, cy} there when the tile goes from from to to pixels.