# `Drafter.Widget.Digits.Raster`
[🔗](https://github.com/jaman/drafter/blob/main/lib/drafter/widget/digits/raster.ex#L1)

Rasterises `Drafter.Widget.Digits.Bitmap` glyphs into terminal cells.

Three packings put multiple pixels in one cell: `:braille` (2×4), `:quadrant`
(2×2), and `:half` (1×2). The chart pixel packer supplies the cell
characters. See the [large text guide](large_text.md) for how the packings
compare.

## Examples

    iex> Drafter.Widget.Digits.Raster.cell_pixels(:braille)
    {2, 4}

    iex> Drafter.Widget.Digits.Raster.shrink(:quadrant)
    {1, 2}

    iex> font = Drafter.Widget.Digits.Raster.font(:braille)
    iex> {font.width, font.height}
    {4, 4}

# `packing`

```elixir
@type packing() :: :braille | :quadrant | :half
```

# `cell_pixels`

```elixir
@spec cell_pixels(packing()) :: {pos_integer(), pos_integer()}
```

Pixels a cell holds, as `{across, down}`, for a packing.

# `font`

```elixir
@spec font(packing()) :: %{height: pos_integer(), width: pos_integer(), glyphs: map()}
```

Rasterise every bitmap into a font map for `Drafter.Widget.Digits.Font`.

Returns `%{height: rows, width: columns, glyphs: %{character => [row, ...]}}`.

# `glyph`

```elixir
@spec glyph(packing(), MapSet.t(), pos_integer(), pos_integer()) :: [String.t()]
```

Rasterise one set of lit pixels into `rows` strings of `columns` cells.

# `shrink`

```elixir
@spec shrink(packing()) :: {pos_integer(), pos_integer()}
```

Divisors applied to the bitmap before rasterising, as `{x, y}`.

`:braille` reads the bitmap at full resolution. The coarser packings halve the
rows; a shrunk pixel is lit when any pixel it covers was lit.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
