Cauldron2D.Drafter.Surface.Scale (Cauldron2D.Drafter v0.1.2)

Copy Markdown View Source

How a tile maps onto the terminal's pixels once the session knows the size of a cell.

A tile is drawn at a whole multiple of its own pixels, or shrunk by a divisor of its size, whichever comes nearest to zoom rows of cells — so every image is sent at the size it is shown and the terminal scales nothing.

scale = Cauldron2D.Drafter.Surface.Scale.new({14, 30}, 16, 1)
scale.pixels
#=> 32

Summary

Functions

The scale for a terminal whose cells are cell pixels, an atlas whose tiles are tile pixels square, at zoom (1 a tile the height of a row).

The pane rect (in cells) in pixels.

Where a point tiles from the pane's top left falls: {column, row, x_offset, y_offset}, the cell and the pixels into it.

A fraction of a tile as whole drawn pixels.

How many tiles across and down the pane rect shows, fractional at the edges.

Types

factor()

@type factor() :: {:magnify, pos_integer()} | {:reduce, pos_integer()}

t()

@type t() :: %Cauldron2D.Drafter.Surface.Scale{
  cell: {pos_integer(), pos_integer()},
  factor: factor(),
  pixels: pos_integer(),
  tile: pos_integer()
}

Functions

new(cell, tile, zoom)

@spec new({pos_integer(), pos_integer()}, pos_integer(), number()) :: t()

The scale for a terminal whose cells are cell pixels, an atlas whose tiles are tile pixels square, at zoom (1 a tile the height of a row).

pane(scale, rect)

@spec pane(t(), map()) :: {pos_integer(), pos_integer()}

The pane rect (in cells) in pixels.

place(scale, arg)

@spec place(t(), {number(), number()}) :: {integer(), integer(), integer(), integer()}

Where a point tiles from the pane's top left falls: {column, row, x_offset, y_offset}, the cell and the pixels into it.

scroll(scale, arg)

@spec scroll(t(), {number(), number()}) :: {integer(), integer()}

A fraction of a tile as whole drawn pixels.

tiles(scale, rect)

@spec tiles(t(), map()) :: {float(), float()}

How many tiles across and down the pane rect shows, fractional at the edges.