# `Macaw.Draw.Layout.Partition`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/layout/partition.ex#L1)

Adjacency diagrams (spec/08 §5): icicles, and sunbursts when `size` is `{2π, radius}` and
`x0`/`x1` are read as angles in radians.

    iex> alias Macaw.Draw.Layout.{Hierarchy, Partition}
    iex> {:ok, root, []} = Hierarchy.stratify(~w(r a b), [nil, "r", "r"], [])
    iex> {:ok, partition} = Partition.new(size: {10, 4})
    iex> laid = Partition.generate(partition, Hierarchy.count(root))
    iex> Enum.map(laid.children, &{&1.x0, &1.y0, &1.x1, &1.y1})
    [{0, 2.0, 5.0, 4.0}, {5.0, 2.0, 10.0, 4.0}]

| Option | Type | Default |
|---|---|---|
| `size` | `{w, h}` | `{1, 1}` |
| `padding` | non-negative number | `0` |
| `round` | boolean | `false` |

The root occupies `x0 = 0`, `x1 = w`, `y0 = 0`, `y1 = h / (root.height + 1)`. Each child
receives a share of its parent's extent, less `padding` between siblings, proportional to
its weight (its `value` when that is a number above 0, else 0), one level lower. Every
child is retained: a child of weight 0 receives a zero-width rectangle at its running
offset. This is visualize's `Visualize.Layout.Partition`.

# `t`

```elixir
@type t() :: %Macaw.Draw.Layout.Partition{
  padding: number(),
  round: boolean(),
  size: {number(), number()}
}
```

# `columns`

```elixir
@spec columns(Macaw.Draw.Layout.Hierarchy.t(), atom() | String.t(), keyword()) ::
  %{required(String.t()) =&gt; [term()]} | Macaw.Draw.Layout.error()
```

The columns of a partition (§3.5): `:nodes` with `"x0"`, `"y0"`, `"x1"`, `"y1"`; a
partition has no `:links` output, and asking for one is a fault.

# `generate`

```elixir
@spec generate(t(), Macaw.Draw.Layout.Hierarchy.t()) ::
  Macaw.Draw.Layout.Hierarchy.t() | Macaw.Draw.Layout.error()
```

Every node of `root` given its rectangle, `x0`, `y0`, `x1`, `y1` (§5).

# `new`

```elixir
@spec new() :: {:ok, t()}
```

`new/1` with every option at its default.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | Macaw.Draw.Layout.error()
```

The layout of `opts` (§5): `{:ok, partition}` or `{:error, faults}`.

---

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