Macaw.Frame.ThemeSheet (macaw_frame v0.1.0)

Copy Markdown View Source

The theme mode's frame side (spec/02 §17), copied from visualize's Visualize.Chart.Builder.ThemeSheet without its LiveView markup: what an editor of any kind needs from macaw_frame to show what a theme does to a Frame. The editor itself is out of scope.

  • samples/0 is the fixed set a theme is judged on, each %{id, title, design, rows}: series (eight lines in the categorical series over axes), status (five bars in the five roles), thermal (cells on a sequential scale over the thermal ramp), diverging (bars either side of zero over the diverging ramp) and axes, grid and text (a titled line chart with both axes, a grid and an axis label). rows are each slot's rows.

  • render/2 draws a chrome card of every series color and the furniture colors as swatches, then every sample, under the theme in :literal mode, so no page stylesheet re-points a slot under it, each over its frame's background: {:ok, cards}, each card %{id, title, svg}. Each sample is compiled (Macaw.Frame.Document.compile/3), its model realized over its rows, its furniture drawn by the model, and its marks drawn here through Macaw.Draw (lines and bars; the layer kinds draw a Frame's with #10).

  • A theme that breaks a contract still draws: a ramp that cannot be drawn at all, or an empty series, draws as the default theme's (drawable/1), and the contract's faults are answered beside the drawings, {:ok, cards, faults}, each {[:ramps, name], {:contract, message}} (or :colors, :styles).

  • vision: (:normal, :deuteranopia, :protanopia, :tritanopia) draws every card as the deficiency sees it, through Macaw.Layers.Color.Vision (Machado, Oliveira and Fernandes 2009 at severity 1.0); since the sheet is literal, every color drawn is simulated.

  • designs: adds a host's designs, each %{id, title, design, rows}, compiled under the theme with its own rows; one that does not compile answers its faults in its card, %{id, title, svg: nil, faults}. registry: is compile/3's.

    iex> Enum.map(Macaw.Frame.ThemeSheet.samples(), & &1.id) ["series", "status", "thermal", "diverging", "axes"]

Summary

Types

A card of the sheet.

Functions

The theme with every ramp it cannot draw (an anchor that resolves to no color, fewer than two) and an empty series replaced by the default theme's, so a sheet always draws while its contract's faults are answered beside it (§17).

The sheet of theme (§17): {:ok, cards}, the chrome card then every sample (then each of designs:), or {:ok, cards, faults} when the theme breaks a contract. Options: vision: (:normal), designs: ([]), registry:. A theme that is no %Macaw.Layers.Theme{} is {:type, :theme} at [:theme], a vision of no deficiency {:enum, visions} at [:vision].

The fixed samples (§17), each %{id, title, design, rows}: series, status, thermal, diverging, and axes, grid and text.

Types

card()

@type card() :: %{
  :id => String.t(),
  :title => String.t(),
  :svg => String.t() | nil,
  optional(:faults) => [Macaw.Base.Fault.t()]
}

A card of the sheet.

Functions

drawable(theme)

The theme with every ramp it cannot draw (an anchor that resolves to no color, fewer than two) and an empty series replaced by the default theme's, so a sheet always draws while its contract's faults are answered beside it (§17).

render(theme, opts \\ [])

@spec render(term(), keyword()) ::
  {:ok, [card()]}
  | {:ok, [card()], [Macaw.Base.Fault.t(), ...]}
  | {:error, list()}

The sheet of theme (§17): {:ok, cards}, the chrome card then every sample (then each of designs:), or {:ok, cards, faults} when the theme breaks a contract. Options: vision: (:normal), designs: ([]), registry:. A theme that is no %Macaw.Layers.Theme{} is {:type, :theme} at [:theme], a vision of no deficiency {:enum, visions} at [:vision].

samples()

@spec samples() :: [%{id: String.t(), title: String.t(), design: map(), rows: map()}]

The fixed samples (§17), each %{id, title, design, rows}: series, status, thermal, diverging, and axes, grid and text.