Packages

The drawing library of the Macaw family: scales, shapes, layouts and geo, and the scene with its SVG, canvas, binary canvas and raster renderers. Pure functions, errors as values; no data layer, component or Phoenix.

Current section

Files

Jump to
macaw_draw README.md
Raw

README.md

<img src="brand/logo/macaw_scarlet.svg" alt="The Macaw logo, a scarlet macaw in flight" width="128">

# macaw_draw

> **This software is a very early release, and not ready for general use.**

Public home: [github.com/dcoai/macaw_draw](https://github.com/dcoai/macaw_draw) · Docs: [hexdocs.pm](https://hexdocs.pm/macaw_draw)

The drawing library of the Macaw family, `Macaw.Draw`: pure functions that turn numbers, times, points, hierarchies and geometry into a scene, and a scene into SVG, canvas commands, a binary canvas stream or a PNG ([spec/00](https://github.com/dcoai/macaw_draw/blob/main/spec/00-overview.md)). It depends on `macaw_base`, `macaw_layers`, `macaw_units` and `macaw_format` only, so an application draws (a chart image on a server, a printout) with no data layer, component or Phoenix. macaw_frame's Frame is built on it (dco-tek/macaw/macaw#478).

| Namespace | What it is |
|---|---|
| `Macaw.Draw.Scale`, `Ticks`, `Axis`, `Format`, `Quantity` | scales of every kind, d3's tick rule, axes as scene elements, tick formats, quantity display ([spec/06](https://github.com/dcoai/macaw_draw/blob/main/spec/06-draw-scales.md)) |
| `Macaw.Draw.Shape`, `Interpolate`, `Ease`, `Text`, `Polygon`, `Random`, `Units`, `SVG`, `Generators` | lines, areas, arcs, symbols, bands and curves; interpolators, easing, text width, polygon measures, seeded variates, lengths, a plain SVG builder ([spec/07](https://github.com/dcoai/macaw_draw/blob/main/spec/07-draw-shapes.md)) |
| `Macaw.Draw.Layout` | trees, treemaps, packs, partitions, force, sankey, chord, hexbin and the diagram layouts ([spec/08](https://github.com/dcoai/macaw_draw/blob/main/spec/08-draw-layouts.md)) |
| `Macaw.Draw.Geo`, `Contour` | projections, clipping, paths, tiles, the viewport, Delaunay, Voronoi, contours and density ([spec/09](https://github.com/dcoai/macaw_draw/blob/main/spec/09-draw-geo.md)) |
| `Macaw.Draw.IR`, `Render` | the scene and its renderers: SVG, canvas commands, the binary and incremental canvas, motion, keyed segments, the raster through resvg ([spec/10](https://github.com/dcoai/macaw_draw/blob/main/spec/10-rendering.md)) |

Every public function answers a value, `{:ok, value}` or `{:error, faults}`, for any input; only a `!` twin raises, `Macaw.Draw.Error`. The raster target runs a resvg binary named by its `:resvg` option or found on the `PATH`, and draws with the bundled DejaVu Sans faces.

## Installation

Four runtime dependencies, `macaw_base`, `macaw_layers`, `macaw_units` and `macaw_format`. From Hex:

```elixir
{:macaw_draw, "~> 0.1.0"}
```

Part of [Macaw](https://github.com/dcoai/macaw).

## License

MIT; see the LICENSE file. The bundled DejaVu faces are under the Bitstream Vera license with DejaVu's changes in the public domain; see `priv/fonts/LICENSE`.