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

Draws `Drafter.Widget.Slider` through the `french_curve` rasteriser.

One drawing path with two outputs: a transmitted picture for terminals speaking the
kitty, iTerm2 or sixel protocol, and braille `Drafter.Draw.Strip`s for any other
truecolor terminal. Both draw the same shape — a rounded track, a rounded fill up to
the value, and a disc for the thumb — so the slider keeps its outline wherever it is
drawn.

A `t:spec/0` describes what to draw; the caller supplies the cell box and this module
picks the pixel resolution. Every function returns `nil` rather than raising when the
box has no area or the drawing fails, and the widget falls back to characters.

# `rgba`

```elixir
@type rgba() :: {0..255, 0..255, 0..255, 0..255}
```

# `spec`

```elixir
@type spec() :: %{
  fraction: float(),
  orientation: :horizontal | :vertical,
  track: rgba(),
  fill: rgba(),
  thumb: rgba()
}
```

What to draw: where the thumb sits, which way the slider runs, and the colours of
the track, the fill behind the thumb and the thumb itself.

# `braille_strips`

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

Renders `spec` as `rows` braille strips of `cols` cells, or `nil` when it cannot be
drawn.

# `image`

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

Renders `spec` into a `{paint, clear}` pair for a `cols` by `rows` cell box.

Returns `nil` when the terminal has no pixel protocol or the box has no area.

# `mode`

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

How a slider with this `renderer` should be drawn: `:pixel`, `:braille` or `:text`.

Resolution follows `Drafter.Widget.Chart.Pixel.resolve/1`, so the `DRAFTER_MODE`
environment variable wins over a per-widget `renderer`, which wins over the mode the
app was run with. A mode asking for pixels on a terminal with no graphics protocol
falls back to braille.

# `protocol`

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

The pixel protocol in use, or `nil` when the terminal has none.

# `raster`

```elixir
@spec raster(
  spec(),
  {integer(), integer()}
) :: FrenchCurve.Raster.t() | nil
```

Draws `spec` into a raster `width` by `height` pixels.

Returns `nil` for a raster with no area.

---

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