API Reference macaw_draw v#0.1.0

Copy Markdown View Source

Modules

Macaw's drawing library: pure functions with no processes and no state.

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).

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).

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.

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).

The exception every Macaw.Draw ! twin raises (spec/06 §1.2).

The tick format derived from a realized scale, as data (spec/06 §18).

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.

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.

Planar Delaunay triangulation (spec/09 §9), copied from visualize's Visualize.Geo.Delaunay and the delaunay step of its Visualize.Chart.Transform.Geo.

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.

GeoJSON drawn as Macaw.Draw.IR.Paths 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.

Map projections: {longitude, latitude} degrees to {x, y} pixels and back (spec/09 §2), copied from visualize's Visualize.Geo.Projection.

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.

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).

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.

A scene node (spec/10 §1.1), copied from visualize's Visualize.IR.Element.

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).

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).

A path as data: drawing commands and their SVG path string (spec/10 §1.2), copied from visualize's Visualize.IR.Path.

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.

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.

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.

Chord diagrams: a square flow matrix laid out as arcs on a circle with ribbons between them (spec/08 §7).

The dendrogram: a node-link diagram whose leaves all sit at one depth (spec/08 §3.3).

The force simulation as one pure value, stepped by whoever holds it (spec/08 §9).

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.

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.

A Gantt layout (spec/08 §14.3), as Macaw.Draw.Layout.Gantt.generate/3 answers it

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).

Hexagonal binning of points of the plane, d3-hexbin's lattice (spec/08 §10).

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.

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.

A layered drawing (spec/08 §11.8), as Macaw.Draw.Layout.Layered.generate/4 answers it.

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.

Circle packing (spec/08 §4): every node a circle, leaves sized by value and internal nodes enclosing their children.

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

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).

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.

Sequence lanes (spec/08 §12): a sequence diagram's participants as lanes across and its events down, the second cut's sequence diagram layout.

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

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.

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.

The tidy tree, for node-link diagrams (spec/08 §3.2).

Treemaps: nested rectangles whose areas are proportional to value (spec/08 §6).

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.

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).

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}.

The dispatch over targets (spec/10 §2), copied from visualize's Visualize.Render and Visualize.Backend.

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).

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.

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.Elements 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.

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.

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.

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.

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).

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.

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).

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).

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.

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.

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.

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).

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).

A discrete scale dividing a numeric range into uniform bands, one per category (spec/06 §10): what a bar chart places its bars by.

The protocol every scale module implements, and normalize/3 (spec/06 §2.3).

Sequential and diverging color scales, and the d3 schemes (spec/06 §14).

A continuous linear scale, a numeric domain to a numeric range (spec/06 §4).

A continuous logarithmic scale, for data spanning orders of magnitude (spec/06 §5).

A discrete scale, a category to a range element (spec/06 §9).

A continuous power scale: d3's signed power, sqrt its exponent 0.5 (spec/06 §6).

A discretizing scale by sample quantiles: each range element stands for an equal share of the samples (spec/06 §11).

A discretizing scale by uniform buckets: the domain divided into as many equal segments as the range has elements (spec/06 §12).

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).

A continuous symmetric-log scale, for data spanning orders of magnitude through zero (spec/06 §7).

A discretizing scale by explicit thresholds (spec/06 §13): n thresholds divide the numbers into n + 1 buckets, one per range element.

A continuous scale over instants, with calendar ticks and a display zone (spec/06 §8).

The shape facade (spec/07 §2), copied from visualize's Visualize.Shape: constructors for every generator, and setters dispatched on the generator's struct.

An annular sector, d3-shape's arc (spec/07 §6), copied from visualize's Visualize.Shape.Arc.

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

A state timeline: one rectangle per datum (spec/07 §11), copied from visualize's Visualize.Shape.Band.

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.

A line through points (spec/07 §3), copied from visualize's Visualize.Shape.Line.

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.

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).

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.

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.

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.

A point symbol of a given area (spec/07 §9), copied from visualize's Visualize.Shape.Symbol.

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.

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).

The one tick rule, and the tick count from an axis length (spec/06 §16).

Lengths with screen units, and world lengths (spec/07 §23), copied from visualize's Visualize.Units.