# `Macaw.Draw.Shape.Band`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/shape/band.ex#L1)

A state timeline: one rectangle per datum (spec/07 §11), copied from visualize's
`Visualize.Shape.Band`.

Each datum spans `x0` to `x1` at `y`, `height` tall, filled per datum. The four
coordinates are pixel accessors: the caller (a layer) applies the x scale. `new/0` reads
tuple elements 0 and 1 as the edges, with `y = 0` and `height = 10`:

    iex> alias Macaw.Draw.Shape.Band
    iex> [rect] = Band.generate(Band.new(), [{50, 10}])
    iex> {rect.type, rect.attrs, rect.style}
    {:rect, %{x: 10, y: 0, width: 40, height: 10}, %{class: "band"}}

`generate/2` answers one `:rect` element per datum in data order, `x` the lesser edge
and `width` non-negative, its style `%{class: "band"}` plus `fill:` when the fill
accessor answers a value. Coinciding edges give a zero-width rectangle; **a datum with an
undefined coordinate is not emitted** (§1.1). `generate_path/2` folds the rectangles into
one path, the fill playing no part. The fill is a function, an atom field, or a color
value of macaw_layers.

# `accessor`

```elixir
@type accessor() :: (term() -&gt; term()) | atom() | String.t() | number()
```

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `t`

```elixir
@type t() :: %Macaw.Draw.Shape.Band{
  fill: (term() -&gt; term()) | nil,
  height: (term() -&gt; term()) | number(),
  x0: (term() -&gt; term()) | nil,
  x1: (term() -&gt; term()) | nil,
  y: (term() -&gt; term()) | number()
}
```

# `fill`

```elixir
@spec fill(t(), term()) :: t() | error()
```

Sets the fill: a function, an atom field, or a color value; `nil` unsets it.

# `generate`

```elixir
@spec generate(t(), [term()]) :: [Macaw.Draw.IR.Element.t()] | error()
```

One `:rect` element per drawn datum, in data order.

# `generate_path`

```elixir
@spec generate_path(t(), [term()]) :: Macaw.Draw.IR.Path.t() | error()
```

One `Macaw.Draw.IR.Path` of closed rectangles, in data order.

# `height`

```elixir
@spec height(t(), accessor()) :: t() | error()
```

Sets the height accessor, in pixels: a function, a field, or a number.

# `new`

```elixir
@spec new() :: t()
```

A band reading tuple elements 0 and 1 as its edges, `y = 0` and `height = 10`.

# `x0`

```elixir
@spec x0(t(), accessor()) :: t() | error()
```

Sets the start edge accessor, in pixels: a function, a field, or a number.

# `x1`

```elixir
@spec x1(t(), accessor()) :: t() | error()
```

Sets the end edge accessor, in pixels: a function, a field, or a number.

# `y`

```elixir
@spec y(t(), accessor()) :: t() | error()
```

Sets the top accessor, in pixels: a function, a field, or a number.

---

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