# `Drafter.Widget.Chart.Pixel`
[🔗](https://github.com/jaman/drafter/blob/main/lib/drafter/widget/chart/pixel.ex#L1)

Renders chart data as terminal graphics via the frozen `french_curve` library.

Two outputs from a single rasterisation path: a true-image escape sequence for
terminals that support a pixel protocol (kitty / iTerm2 / sixel), or anti-aliased
braille `Strip`s for any other truecolor terminal. Callers pick the mode with
`mode/2` ("best available" for `:pixel`) and pass a chart `spec` to `image/4`
(a `{paint, clear}` pair — `clear` is a kitty delete for the persistent-layer
protocol, empty for cell-grid protocols) or `braille_strips/2`.

A `spec` is `%{type, values, color: {r,g,b,a}, smooth, fill_opacity, min, max}`.
Add a `raster/3` clause to support a new chart type; `supported/0` gates which
types use this path at all.

# `braille_strips`

```elixir
@spec braille_strips(
  map(),
  {pos_integer(), pos_integer()}
) :: [Drafter.Draw.Strip.t()] | nil
```

# `image`

```elixir
@spec image(map(), atom(), {pos_integer(), pos_integer()}, term()) ::
  {iodata(), iodata()} | nil
```

# `mode`

```elixir
@spec mode(atom() | nil, atom()) :: :pixel | :braille | :text
```

# `modes`

```elixir
@spec modes() :: [atom()]
```

The list of mode atoms accepted by `:renderer`, `DRAFTER_MODE`, and the `mode:`
run option: `[:auto, :pixel, :kitty, :iterm2, :sixel, :braille, :text]`.

# `protocol`

```elixir
@spec protocol(atom() | nil) :: atom() | nil
```

The graphics protocol to draw with, or `nil` when the terminal has none.

A `renderer` naming a protocol (`:kitty`, `:iterm2`, `:sixel`) is used as given;
any mode that is not `:auto` or `:pixel` has no protocol and returns `nil`.

`:auto` and `:pixel` take what the terminal answered when it was probed at
startup — see `Drafter.Terminal.Probe`. A terminal that was never probed is
guessed at from its environment instead, through
`FrenchCurve.Capability.detect/1`.

Either way the terminal in question is the one this session is attached to, which
for a session served over ssh or telnet is the connecting client's rather than
the host's.

# `resolve`

```elixir
@spec resolve(atom() | nil) :: atom()
```

Resolve an effective mode from precedence: the `DRAFTER_MODE` env var forces and
wins over everything; otherwise an explicit per-widget `renderer` (any mode atom),
then the runtime `:drafter` `:render_mode` application env, then `:text`.

# `supported`

```elixir
@spec supported() :: [atom()]
```

---

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