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

A shaded interval between two domain values, with an optional label (spec/07 §13),
copied from visualize's `Visualize.Shape.XBand`: an incident, a maintenance window,
under the rule's model.

`x0`/`x1` are domain accessors mapped by `scale/2` (no scale: pixels), `y0`/`y1` the
pixel extent. `new/0` reads tuple elements 0 and 1 as the edges and fills the region as
a brush selection is filled, `Macaw.Layers.Color.rgb(119, 119, 119, 0.2)`:

    iex> alias Macaw.Draw.Shape.XBand
    iex> [group] = XBand.generate(XBand.new(), [{30, 10}])
    iex> [rect] = group.children
    iex> rect.attrs
    %{x: 10, y: 0, width: 20, height: 100}

`generate/2` answers one `:group` per datum, `style: %{class: "x-band"}`: a `:rect`
between the mapped edges and, with a label, a `:text` at its top left. An edge the scale
places nowhere draws nothing for its datum. The fill is a function, an atom field, or a
color value; the label a function, an atom field, or a string.

# `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.XBand{
  fill: (term() -&gt; term()) | nil,
  label: (term() -&gt; term()) | nil,
  scale: struct() | nil,
  x0: (term() -&gt; term()) | nil,
  x1: (term() -&gt; term()) | nil,
  y0: (term() -&gt; term()) | number(),
  y1: (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 `:group` element per drawn datum: the rectangle, then the label when there is one.

# `label`

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

Sets the label: a function, an atom field, or a string; `nil` clears it.

# `new`

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

An x-band reading tuple elements 0 and 1 as its edges, extent `0` to `100`, the brush's fill.

# `scale`

```elixir
@spec scale(t(), struct() | nil) :: t() | error()
```

Sets the x scale the edges map through; `nil` means the values are pixels.

# `x0`

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

Sets the first edge's domain value accessor: a function, a field, or a number.

# `x1`

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

Sets the second edge's domain value accessor: a function, a field, or a number.

# `y0`

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

Sets the first vertical extent accessor: a function, a field, or a number.

# `y1`

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

Sets the second vertical extent accessor: a function, a field, or a number.

---

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