# `Macaw.Frame.Coordinates.Layout`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/coordinates/layout.ex#L1)

The layout model (spec/03 §9): a layout assigns the positions, and **the frame runs its
layout once** per realization; its layers read the layout's outputs.

- **What it owns** (§9.1): the key `layout` (absent when the frame's layers lay
  themselves out by their spatial steps, as the catalog's hierarchies and graphs do,
  spec/13 §5), a node of `kind` (or `op`, a layout's
  name: `tree`, `cluster`, `pack`, `partition`, `treemap`, `sankey`, `chord`, `force`),
  its options, and its slots: `nodes` (a hierarchy's single slot, a graph's optional
  node slot) and `links` (a graph's flows). A hierarchy's rows carry `id` and `parent`
  (and `value`); a network's links `source`, `target` and `value`, its nodes `id`. An op
  the drawing library lacks is `{:unknown, :layout, name}` at the layout's `kind`. The
  default margin is zero.
- **One run per realization** (§9.2): `realize/3` runs the layout over its slots'
  deliveries through `Macaw.Draw.Layout`'s modules and holds one table per output
  (`nodes`, `links`, `groups`, `chords`) as the model's `layout`; a layer reading
  `output: "links"` (the document's `data: %{"layout" => "links"}`) reads that table.
  The run repeats only on a delivery to a slot it reads and on `size`. **A warm force**
  starts from the carried simulation (`warm:`), reheated to `alpha` 0.3 and stepped at
  most 3 ticks; a cold one runs d3's 300 from alpha 1.
- **Placement and furniture** (§9.3): every positional channel is pixels; `place/2` of
  `{id}` is the node's position; no axes on positions and no grid; `size` defaults to the
  plot, a ring's center is the plot's center.
- **Hit-testing, writes and summary** (§9.4): a pick of a node emits its identity, of a
  link its `source` and `target` when the slot declares none; `invert/2` is `:none`; the
  summary names the layout's kind, its node and link counts, a hierarchy's depth.

# `gesture`

A pick (§9.4): of a node, its declared identity (its slot's, else its `id`); of a link,
its `source` and `target` pair when the links slot declares none.

# `linked`

```elixir
@spec linked(Macaw.Frame.Coordinates.Model.t(), term()) :: [non_neg_integer()]
```

The layers to outline when a node is hovered (§9.4): each `{layer, row}` of the link
outputs whose `source` or `target` is the node's identity, read by column.

# `ops`

```elixir
@spec ops() :: [String.t()]
```

The layouts a layout frame may run.

# `run`

```elixir
@spec run(term(), term(), term(), term()) :: {:ok, map()} | {:error, list()}
```

The layout run over its slots (§9.2): `{:ok, %{op, outputs, simulation, depth}}`,
`outputs` a `Macaw.Data.Table` per output, or the layout's faults. `slots` holds each
slot's `%{table: ...}`; `warm` a force simulation carried from the last realization.

# `slots`

```elixir
@spec slots(term()) :: %{required(String.t()) =&gt; {String.t(), [String.t()]}}
```

The slots a layout node reads (§9.1), each with the roles it reads from it:
`%{"nodes" => {slot, roles}, "links" => {slot, roles}}`.

---

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