# macaw_draw v0.1.0 - API Reference

## Modules

- [Macaw.Draw](Macaw.Draw.md): Macaw's drawing library: pure functions with no processes and no state.
- [Macaw.Draw.Axis](Macaw.Draw.Axis.md): A reference axis as scene elements: its domain line, tick marks and labels (spec/06
§17), d3-axis's geometry (visualize `Visualize.Axis`, D-23, D-55, D-56).
- [Macaw.Draw.Contour](Macaw.Draw.Contour.md): Iso-lines through a scalar grid by marching squares (spec/09 §11), copied from
visualize's `Visualize.Contour` and the `contour` step of its
`Visualize.Chart.Transform.Geo` (visualize D-72, D-112).
- [Macaw.Draw.Contour.Density](Macaw.Draw.Contour.Density.md): Two-dimensional Gaussian kernel density over pixel positions, contoured (spec/09 §12),
copied from visualize's `Visualize.Contour.Density` and the `density` step of its
`Visualize.Chart.Transform.Geo`.
- [Macaw.Draw.Ease](Macaw.Draw.Ease.md): The 25 easing curves (spec/07 §18), copied from visualize's `Visualize.Ease`: functions
from `t` in `[0, 1]` to a float, nominally in `[0, 1]` (the `elastic_*` and `back_*`
families overshoot).
- [Macaw.Draw.Format](Macaw.Draw.Format.md): The tick format derived from a realized scale, as data (spec/06 §18).
- [Macaw.Draw.Generators](Macaw.Draw.Generators.md): Styles and colors a design names and the frame computes at render (spec/07 §25;
visualize spec/14 §3.13, D-177), copied from visualize's `Visualize.Generators`: the
stored call, the host module's macro, and the registry.
- [Macaw.Draw.Geo.Circle](Macaw.Draw.Geo.Circle.md): A circle on the sphere as a GeoJSON `Polygon`: d3-geo's `geoCircle` (spec/09 §5,
visualize #525, D-131), copied from visualize's `Visualize.Geo.Circle`.
- [Macaw.Draw.Geo.Delaunay](Macaw.Draw.Geo.Delaunay.md): Planar Delaunay triangulation (spec/09 §9), copied from visualize's
`Visualize.Geo.Delaunay` and the `delaunay` step of its `Visualize.Chart.Transform.Geo`.
- [Macaw.Draw.Geo.Graticule](Macaw.Draw.Geo.Graticule.md): The graticule, d3-geo's `geoGraticule`: meridians, parallels and their outline as
GeoJSON that `Macaw.Draw.Geo.Path` clips and projects like any geometry (spec/09 §6).
visualize had none; this is a port of d3-geo's `src/graticule.js`.
- [Macaw.Draw.Geo.Path](Macaw.Draw.Geo.Path.md): GeoJSON drawn as `Macaw.Draw.IR.Path`s and measured in projected space (spec/09 §4),
copied from visualize's `Visualize.Geo.Path` and the projection step of its
`Visualize.Chart.Transform.Geo`.
- [Macaw.Draw.Geo.Projection](Macaw.Draw.Geo.Projection.md): Map projections: `{longitude, latitude}` degrees to `{x, y}` pixels and back
(spec/09 §2), copied from visualize's `Visualize.Geo.Projection`.
- [Macaw.Draw.Geo.Tiles](Macaw.Draw.Geo.Tiles.md): The arithmetic of a slippy-map basemap (spec/09 §7, visualize #475), copied from
visualize's `Visualize.Geo.Tiles`: whether a projection has tiles, the zoom level whose
256-pixel tiles match it, the tiles covering a plot, where each goes in plot pixels, and
the values of its address.
- [Macaw.Draw.Geo.Viewport](Macaw.Draw.Geo.Viewport.md): A geographic view, a projection and a plot size, as the `:point` box window of
`macaw_data` and back, and the pan and zoom gestures that move it (spec/09 §8).
- [Macaw.Draw.Geo.Voronoi](Macaw.Draw.Geo.Voronoi.md): Voronoi cells bounded to a rectangle (spec/09 §10), copied from visualize's
`Visualize.Geo.Voronoi` and the `voronoi` step of its `Visualize.Chart.Transform.Geo`.
- [Macaw.Draw.IR.Element](Macaw.Draw.IR.Element.md): A scene node (spec/10 §1.1), copied from visualize's `Visualize.IR.Element`.
- [Macaw.Draw.IR.Motion](Macaw.Draw.IR.Motion.md): The motion values every target writes (spec/10 §1.5, §5), copied from visualize's
`Visualize.IR.Motion` (visualize spec/14 §3.10–§3.12, D-176).
- [Macaw.Draw.IR.Paint](Macaw.Draw.IR.Paint.md): A paint that is not one color (spec/10 §1.4), copied from visualize's
`Visualize.IR.Paint`: the value of a node's `:fill` or `:stroke` when it is a gradient
or a hatch (visualize spec/02 §2.1, #652, D-175).
- [Macaw.Draw.IR.Path](Macaw.Draw.IR.Path.md): A path as data: drawing commands and their SVG path string (spec/10 §1.2), copied from
visualize's `Visualize.IR.Path`.
- [Macaw.Draw.IR.Transform](Macaw.Draw.IR.Transform.md): A node's transform (spec/10 §1.3), copied from visualize's `Visualize.IR.Transform`:
`%Macaw.Draw.IR.Transform{operations}`, applied left to right as SVG composes them.
- [Macaw.Draw.Interpolate](Macaw.Draw.Interpolate.md): Interpolator factories (spec/07 §17), copied from visualize's `Visualize.Interpolate`:
each answers `{:ok, fun}`, `fun` a 1-arity function of `t`, or `{:error, faults}` for
endpoints it cannot interpolate, and has a `!` twin answering the function itself.
- [Macaw.Draw.Layout](Macaw.Draw.Layout.md): The conventions every layout shares (spec/08 §1): options checked once and every fault
answered at once, vocabularies read by spelling, and output as columns.
- [Macaw.Draw.Layout.Chord](Macaw.Draw.Layout.Chord.md): Chord diagrams: a square flow matrix laid out as arcs on a circle with ribbons between
them (spec/08 §7).
- [Macaw.Draw.Layout.Cluster](Macaw.Draw.Layout.Cluster.md): The dendrogram: a node-link diagram whose leaves all sit at one depth (spec/08 §3.3).
- [Macaw.Draw.Layout.Force](Macaw.Draw.Layout.Force.md): The force simulation as one pure value, stepped by whoever holds it (spec/08 §9).
- [Macaw.Draw.Layout.Force.Forces](Macaw.Draw.Layout.Force.Forces.md): The seven forces of the force simulation (spec/08 §9.2), each a function of the nodes,
the links, the temperature `alpha` and the force's options.
- [Macaw.Draw.Layout.Gantt](Macaw.Draw.Layout.Gantt.md): The Gantt time grid (spec/08 §14): tasks as bars against a time axis, in rows grouped by
section, with dependency arrows and the grid behind them.
- [Macaw.Draw.Layout.Gantt.Result](Macaw.Draw.Layout.Gantt.Result.md): A Gantt layout (spec/08 §14.3), as `Macaw.Draw.Layout.Gantt.generate/3` answers it
- [Macaw.Draw.Layout.Graph](Macaw.Draw.Layout.Graph.md): A network from a `links` slot and an optional `nodes` slot (spec/08 §1.3): the one graph
every network layout reads (chord, sankey and force; the layered layouts of the second
cut).
- [Macaw.Draw.Layout.Hexbin](Macaw.Draw.Layout.Hexbin.md): Hexagonal binning of points of the plane, d3-hexbin's lattice (spec/08 §10).
- [Macaw.Draw.Layout.Hierarchy](Macaw.Draw.Layout.Hierarchy.md): The tree every hierarchical layout reads (spec/08 §2): `Tree`, `Cluster`, `Pack`,
`Partition` and `Treemap`. A hierarchy is an immutable tree of `%Hierarchy{}` structs;
every operation answers a new root.
- [Macaw.Draw.Layout.Layered](Macaw.Draw.Layout.Layered.md): The layered DAG (spec/08 §11): a directed graph laid out in ranks with routed edges,
Sugiyama-style, the layout of the second cut's flowcharts, state, class and ER diagrams.
- [Macaw.Draw.Layout.Layered.Result](Macaw.Draw.Layout.Layered.Result.md): A layered drawing (spec/08 §11.8), as `Macaw.Draw.Layout.Layered.generate/4` answers it.
- [Macaw.Draw.Layout.Links](Macaw.Draw.Layout.Links.md): A parent-child link's path (spec/08 §3.4): a curve, an elbow or a line from the parent's
position to the child's, vertical or horizontal.
- [Macaw.Draw.Layout.Pack](Macaw.Draw.Layout.Pack.md): Circle packing (spec/08 §4): every node a circle, leaves sized by value and internal
nodes enclosing their children.
- [Macaw.Draw.Layout.Partition](Macaw.Draw.Layout.Partition.md): Adjacency diagrams (spec/08 §5): icicles, and sunbursts when `size` is `{2π, radius}` and
`x0`/`x1` are read as angles in radians.
- [Macaw.Draw.Layout.Radial](Macaw.Draw.Layout.Radial.md): The radial tree and radial dendrogram (spec/08 §15): a tree drawn in polar coordinates,
the root at the center, depth outward, siblings around, over `Macaw.Draw.Layout.Tree`
(§3.2) and `Macaw.Draw.Layout.Cluster` (§3.3).
- [Macaw.Draw.Layout.Sankey](Macaw.Draw.Layout.Sankey.md): Flow diagrams: the nodes and links of a directed weighted graph positioned so a link's
width is its value (spec/08 §8), a port of d3-sankey.
- [Macaw.Draw.Layout.Sequence](Macaw.Draw.Layout.Sequence.md): Sequence lanes (spec/08 §12): a sequence diagram's participants as lanes across and its
events down, the second cut's sequence diagram layout.
- [Macaw.Draw.Layout.Sequence.Result](Macaw.Draw.Layout.Sequence.Result.md): A sequence diagram (spec/08 §12.5), as `Macaw.Draw.Layout.Sequence.generate/3` answers
it, every record's `index` (or `row`) the event it came from
- [Macaw.Draw.Layout.Swimlanes](Macaw.Draw.Layout.Swimlanes.md): Swimlanes (spec/08 §13): a layered graph (`Macaw.Draw.Layout.Layered`) banded into lanes,
an activity diagram or a process map whose nodes each belong to one lane.
- [Macaw.Draw.Layout.Swimlanes.Result](Macaw.Draw.Layout.Swimlanes.Result.md): A swimlane drawing (spec/08 §13.3): `Macaw.Draw.Layout.Layered.Result`'s fields, `nodes`,
`edges`, `width`, `height`, `crossings` and `bounded`, with `lanes`, one per lane in
order, `%{id, x0, y0, x1, y1, label_x, label_y}`: the lane's band and its label's center
in the header.

- [Macaw.Draw.Layout.Tree](Macaw.Draw.Layout.Tree.md): The tidy tree, for node-link diagrams (spec/08 §3.2).
- [Macaw.Draw.Layout.Treemap](Macaw.Draw.Layout.Treemap.md): Treemaps: nested rectangles whose areas are proportional to `value` (spec/08 §6).
- [Macaw.Draw.Polygon](Macaw.Draw.Polygon.md): Polygon measures (spec/07 §21), copied from visualize's `Visualize.Polygon` over lists of
`{x, y}` tuples; a polygon is implicitly closed. Geographic polygons, contours and
Voronoi cells (spec/09) measure through this module.
- [Macaw.Draw.Quantity](Macaw.Draw.Quantity.md): Quantity display: a domain shown in the unit that fits it, its ticks on round numbers of
that unit, and the tick format that labels them (spec/06 §19, visualize D-138, D-156).
- [Macaw.Draw.Random](Macaw.Draw.Random.md): Random variates over an explicit state (spec/07 §22), copied from visualize's
`Visualize.Random`, which read and advanced the calling process's `:rand` state.
`Macaw.Draw` holds no state, so every draw takes a state and answers the value with the
next state, `{value, state}`.
- [Macaw.Draw.Render](Macaw.Draw.Render.md): The dispatch over targets (spec/10 §2), copied from visualize's `Visualize.Render` and
`Visualize.Backend`.
- [Macaw.Draw.Render.Binary](Macaw.Draw.Render.Binary.md): The binary canvas encoder (spec/10 §4.2–§4.6), copied from visualize's
`Visualize.Backend.CanvasBinary`, `.Opcodes` and `.PathEncoder`: a scene packed into a
compact little-endian stream of records the `FrameBinary` hook replays (spec/10 §7.9).
- [Macaw.Draw.Render.Binary.Decoder](Macaw.Draw.Render.Binary.Decoder.md): The reference decoder of the binary canvas (spec/10 §4.8), copied from visualize's
`Visualize.Backend.CanvasBinary.Decoder` and **written from spec/10 §4.2–§4.3 and §4.9,
not from the encoder**, so `decode(encode(x))` is a round trip that tests both
(visualize D-36). Where visualize raised on a bad byte, this answers it: a test or a
host reading a stream it did not write gets a value.
- [Macaw.Draw.Render.Binary.SVG](Macaw.Draw.Render.Binary.SVG.md): The binary encoder of the SVG builder's elements (spec/10 §4.7), copied from visualize's
`Visualize.Backend.CanvasBinary.SVG` and `.SVG.Defs`: a tree of
`Macaw.Draw.SVG.Element`s written to the stream of `Macaw.Draw.Render.Binary`
(spec/10 §4.2–§4.3), reading presentation attributes rather than a style map.
`Macaw.Draw.Render.Binary.encode/2` dispatches a builder tree here.
- [Macaw.Draw.Render.Canvas](Macaw.Draw.Render.Canvas.md): The canvas commands (spec/10 §4.1), copied from visualize's `Visualize.Backend.Canvas`,
`Visualize.Backend.Canvas.Arc` and `Visualize.Backend.Canvas.Output`: a scene written as
Canvas 2D commands.
- [Macaw.Draw.Render.Fonts](Macaw.Draw.Render.Fonts.md): The raster target's font configuration and the bundled faces (spec/10 §9.6): **a
raster never depends on the host's fonts**. New here: visualize's options of
`Visualize.Render.to_png/2` (`:font_dirs`, `:system_fonts`, `:generic_families`), made
one value whose default is the bundled faces with the system's fonts off.
- [Macaw.Draw.Render.Incremental](Macaw.Draw.Render.Incremental.md): The incremental canvas (spec/10 §4.9), copied from visualize's
`Visualize.Backend.CanvasIncremental` and the stale-column scroll of `Visualize.Incremental`
(visualize spec/09 §5, §7, D-38, D-106, D-324): a scrolling plot sends what scrolled in,
not the whole plot.
- [Macaw.Draw.Render.Motion](Macaw.Draw.Render.Motion.md): The motion sheet of a drawing (spec/10 §5), copied from visualize's
`Visualize.Chart.Frame.Motion`, taking resolved styles rather than a chart frame: SVG
moves through CSS, and under the strict CSP that CSS is a **generated stylesheet**,
never a `<style>` in the page (macaw spec/10 §1, rule 3).
- [Macaw.Draw.Render.Raster](Macaw.Draw.Render.Raster.md): The raster target (spec/10 §9), copied from visualize's `Visualize.Render.Raster`: the
package's SVG rasterized to PNG through **resvg run as a port** (visualize D-121,
D-213). It is the one module that runs resvg, so the rasterizer is replaceable in one
place, and the one place the package holds a process: a render's own, for one call.
- [Macaw.Draw.Render.SVG](Macaw.Draw.Render.SVG.md): The SVG renderer (spec/10 §3), copied from visualize's `Visualize.Backend.SVG`: a scene
written as SVG markup, iodata, through the one serializer of tags, attributes and text,
`Macaw.Draw.SVG.Renderer` (spec/10 §3.2, visualize D-34).
- [Macaw.Draw.Render.Segments](Macaw.Draw.Render.Segments.md): A drawing as keyed segments (spec/10 §6), copied from visualize's
`Visualize.Render.Segments`: a change sends only what it touched (visualize spec/09
§1.4, D-203).
- [Macaw.Draw.Render.Target](Macaw.Draw.Render.Target.md): The behavior of a rendering target (spec/10 §2.2), visualize's `Visualize.Backend`:
what `Macaw.Draw.Render.render/3` dispatches a path, a node and a list of nodes to.
- [Macaw.Draw.SVG](Macaw.Draw.SVG.md): The plain SVG builder's fluent API (spec/07 §24; visualize spec/02 §5), copied from
visualize's `Visualize.SVG`: markup for host code and tests without a frame. A frame
draws through the scene IR and its renderers (spec/10), and the builder shares their
attribute naming and escaping, so the two write the same markup for the same element.
- [Macaw.Draw.SVG.Element](Macaw.Draw.SVG.Element.md): An SVG element as data (spec/07 §24), copied from visualize's `Visualize.SVG.Element`:
`%Macaw.Draw.SVG.Element{tag, attrs, children, content}`, mirroring an element one to
one: `tag` an SVG tag atom, `attrs` a map, `children` a list of elements, `content` text
or `nil`.
- [Macaw.Draw.SVG.Renderer](Macaw.Draw.SVG.Renderer.md): The writer of the plain SVG builder (spec/07 §24; visualize D-11, #812), copied from
visualize's `Visualize.SVG.Renderer`: the one serializer of tags, attributes and text
every SVG the package writes goes through (spec/10 §3.2).
- [Macaw.Draw.Scale](Macaw.Draw.Scale.md): The scale facade: constructors, the validating builder `new/2`, and dispatch of the
common operations to the module the scale struct names (spec/06 §2, §3).
- [Macaw.Draw.Scale.Band](Macaw.Draw.Scale.Band.md): A discrete scale dividing a numeric range into uniform bands, one per category
(spec/06 §10): what a bar chart places its bars by.
- [Macaw.Draw.Scale.Behaviour](Macaw.Draw.Scale.Behaviour.md): The protocol every scale module implements, and `normalize/3` (spec/06 §2.3).
- [Macaw.Draw.Scale.Color](Macaw.Draw.Scale.Color.md): Sequential and diverging color scales, and the d3 schemes (spec/06 §14).
- [Macaw.Draw.Scale.Linear](Macaw.Draw.Scale.Linear.md): A continuous linear scale, a numeric domain to a numeric range (spec/06 §4).
- [Macaw.Draw.Scale.Log](Macaw.Draw.Scale.Log.md): A continuous logarithmic scale, for data spanning orders of magnitude (spec/06 §5).
- [Macaw.Draw.Scale.Ordinal](Macaw.Draw.Scale.Ordinal.md): A discrete scale, a category to a range element (spec/06 §9).
- [Macaw.Draw.Scale.Power](Macaw.Draw.Scale.Power.md): A continuous power scale: d3's signed power, `sqrt` its exponent 0.5 (spec/06 §6).
- [Macaw.Draw.Scale.Quantile](Macaw.Draw.Scale.Quantile.md): A discretizing scale by sample quantiles: each range element stands for an equal share
of the samples (spec/06 §11).
- [Macaw.Draw.Scale.Quantize](Macaw.Draw.Scale.Quantize.md): A discretizing scale by uniform buckets: the domain divided into as many equal segments
as the range has elements (spec/06 §12).
- [Macaw.Draw.Scale.Radial](Macaw.Draw.Scale.Radial.md): An angle scale: a cyclic quantity (a compass bearing, an hour of the day, a day of the
year) to radians (spec/06 §15, visualize D-30).
- [Macaw.Draw.Scale.Symlog](Macaw.Draw.Scale.Symlog.md): A continuous symmetric-log scale, for data spanning orders of magnitude through zero
(spec/06 §7).
- [Macaw.Draw.Scale.Threshold](Macaw.Draw.Scale.Threshold.md): A discretizing scale by explicit thresholds (spec/06 §13): `n` thresholds divide the
numbers into `n + 1` buckets, one per range element.
- [Macaw.Draw.Scale.Time](Macaw.Draw.Scale.Time.md): A continuous scale over instants, with calendar ticks and a display zone (spec/06 §8).
- [Macaw.Draw.Shape](Macaw.Draw.Shape.md): The shape facade (spec/07 §2), copied from visualize's `Visualize.Shape`: constructors
for every generator, and setters dispatched on the generator's struct.
- [Macaw.Draw.Shape.Arc](Macaw.Draw.Shape.Arc.md): An annular sector, d3-shape's `arc` (spec/07 §6), copied from visualize's
`Visualize.Shape.Arc`.
- [Macaw.Draw.Shape.Area](Macaw.Draw.Shape.Area.md): A closed area between two edges (spec/07 §4), copied from visualize's
`Visualize.Shape.Area`.
- [Macaw.Draw.Shape.Band](Macaw.Draw.Shape.Band.md): A state timeline: one rectangle per datum (spec/07 §11), copied from visualize's
`Visualize.Shape.Band`.
- [Macaw.Draw.Shape.Curve](Macaw.Draw.Shape.Curve.md): The curve interpolators of lines and areas (spec/07 §5), copied from visualize's
`Visualize.Shape.Curve`: how a run of points is joined into a path.
- [Macaw.Draw.Shape.Line](Macaw.Draw.Shape.Line.md): A line through points (spec/07 §3), copied from visualize's `Visualize.Shape.Line`.
- [Macaw.Draw.Shape.Needle](Macaw.Draw.Shape.Needle.md): A gauge's or compass's pointer (spec/07 §16), copied from visualize's
`Visualize.Shape.Needle`: one filled pointer per datum from the hub to its angle.
- [Macaw.Draw.Shape.PercentileBand](Macaw.Draw.Shape.PercentileBand.md): A median line with an inner and an outer band about it (spec/07 §14), copied from
visualize's `Visualize.Shape.PercentileBand`: the standard reading of a distribution
over time, `Macaw.Draw.Shape.Area` and `Macaw.Draw.Shape.Line` composed with a fixed
output shape (visualize D-28).
- [Macaw.Draw.Shape.Pie](Macaw.Draw.Shape.Pie.md): The angles of a pie, as data (spec/07 §7), copied from visualize's
`Visualize.Shape.Pie`. It draws nothing: `generate/2` answers one arc datum per datum,
in data order, that `Macaw.Draw.Shape.Arc` consumes directly.
- [Macaw.Draw.Shape.Rose](Macaw.Draw.Shape.Rose.md): One sector per datum about its angle (spec/07 §15), copied from visualize's
`Visualize.Shape.Rose`: a wind rose, a compass rose, an hour-of-day clock.
- [Macaw.Draw.Shape.Rule](Macaw.Draw.Shape.Rule.md): A vertical rule at a domain value, with an optional label (spec/07 §12), copied from
visualize's `Visualize.Shape.Rule`: an instant (a deploy, an incident) inside the same
scale and plot as the data.
- [Macaw.Draw.Shape.Symbol](Macaw.Draw.Shape.Symbol.md): A point symbol of a given area (spec/07 §9), copied from visualize's
`Visualize.Shape.Symbol`.
- [Macaw.Draw.Shape.XBand](Macaw.Draw.Shape.XBand.md): 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.
- [Macaw.Draw.Text](Macaw.Draw.Text.md): A text's width, measured through macaw_layers' seam on a resolved measurer, and the
estimate's inverse (spec/07 §20; visualize spec/14 §5.5, #489).
- [Macaw.Draw.Ticks](Macaw.Draw.Ticks.md): The one tick rule, and the tick count from an axis length (spec/06 §16).
- [Macaw.Draw.Units](Macaw.Draw.Units.md): Lengths with screen units, and world lengths (spec/07 §23), copied from visualize's
`Visualize.Units`.

- Exceptions
  - [Macaw.Draw.Error](Macaw.Draw.Error.md): The exception every `Macaw.Draw` `!` twin raises (spec/06 §1.2).

