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

A closed area between two edges (spec/07 §4), copied from visualize's
`Visualize.Shape.Area`.

`new/0` reads `x` from tuple element 0, `y1` from element 1, and sets the baseline `y0`
to the constant `0`:

    iex> alias Macaw.Draw.Shape.Area
    iex> Area.new() |> Area.generate([{0, 0}, {10, 5}])
    "M0,0L10,5L10,0L0,0Z"

The effective accessors are `x0 || x`, `x1 || x`, `y0 || y` and `y1 || y`; `x/2` sets
`x`, `x0` and `x1` together and `y/2` sets `y`, `y0` and `y1` together, so `y/2` after
`new/0` makes the area zero-height. Each defined run of two or more points (§1.2) is one
closed ring: the top edge `(x1, y1)` forward, a line to the bottom edge `(x0, y0)`
reversed, both through the same curve, then `Z`.

`runs_path/2` takes runs already read, each a list of `{{x1, y1}, {x0, y0}}` top and
bottom pairs (§1.4), and `parts/3` cuts each run's ring in two along a boundary without
changing its curve (visualize D-274).

# `accessor`

```elixir
@type accessor() :: Macaw.Draw.Shape.Line.accessor()
```

# `error`

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

A refusal: faults with their paths.

# `pair`

```elixir
@type pair() :: {{number(), number()}, {number(), number()}}
```

A run's points as `runs_path/2` takes them: `{{x1, y1}, {x0, y0}}`, top and bottom.

# `t`

```elixir
@type t() :: %Macaw.Draw.Shape.Area{
  curve: Macaw.Draw.Shape.Curve.curve_type(),
  curve_opts: keyword(),
  defined: (term() -&gt; term()) | nil,
  x: (term() -&gt; term()) | nil,
  x0: (term() -&gt; term()) | nil,
  x1: (term() -&gt; term()) | nil,
  y: (term() -&gt; term()) | nil,
  y0: (term() -&gt; term()) | nil,
  y1: (term() -&gt; term()) | nil
}
```

# `curve`

```elixir
@spec curve(t(), term()) :: {:ok, t()} | error()
```

`curve(area, type, [])`.

# `curve`

```elixir
@spec curve(t(), term(), keyword()) :: {:ok, t()} | error()
```

Sets the curve of both edges and its options: `{:ok, area}`, or `{:error, faults}` for
an unknown type or an option of the wrong type (§5.1).

# `curve!`

```elixir
@spec curve!(t(), term(), keyword()) :: t()
```

As `curve/3`, the area itself, raising `Macaw.Draw.Error` with its faults.

# `defined`

```elixir
@spec defined(t(), (term() -&gt; term()) | nil) :: t() | error()
```

Sets the `defined` predicate (§1.2), a 1-arity function; `nil` clears it.

# `generate`

```elixir
@spec generate(t(), [term()]) :: String.t() | error()
```

The SVG path data of the closed area.

# `generate_path`

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

The closed `Macaw.Draw.IR.Path`: one ring per defined run of two or more points.

# `new`

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

An area with `x` from tuple element 0, `y1` from element 1 and the baseline `y0 = 0`.

# `parts`

```elixir
@spec parts(t(), [[pair()]], (list() -&gt; {list(), list()})) ::
  {Macaw.Draw.IR.Path.t(), Macaw.Draw.IR.Path.t()} | error()
```

The rings of `runs_path/2` in two parts, `{settled, provisional}` (§4; visualize D-274).

`cut` is a 1-arity function from one edge's commands to `{settled, provisional}` command
lists. Each run's edges are generated whole, the top forward and the bottom reversed,
then cut: both wholly provisional makes the run's ring provisional; both cut into two
non-empty parts closes the settled heads into one ring and the provisional tails into
another; anything else keeps the whole ring settled.

# `runs_path`

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

The path of runs already read (§1.4): each run a list of `{{x1, y1}, {x0, y0}}` pairs
made one closed ring, in order, as `generate_path/2` makes a run of defined data.

# `x0`

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

Sets the bottom edge's x accessor.

# `x1`

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

Sets the top edge's x accessor.

# `x`

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

Sets `x`, `x0` and `x1` together.

# `y0`

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

Sets the bottom edge's (the baseline's) y accessor.

# `y1`

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

Sets the top edge's y accessor.

# `y`

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

Sets `y`, `y0` and `y1` together: the area is then zero-height.

---

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