Visualize.Chart.Builder.Glyphs (Visualize v0.2.25)

Copy Markdown View Source

The pictures a drawn enum is chosen by (spec/14 §18.6).

Some enums name a look — the join of a stroke, the shape of a curve, a symbol, a side — and a person chooses a look by seeing it. glyph/2 draws one allowed value of a drawn key as a small inline SVG, in currentColor so it reads in either theme; drawn?/1 says which keys have pictures. A curve is drawn by Visualize.Shape.Line and a symbol by Visualize.Shape.Symbol, so the picture is the library's own work and cannot lie.

This module compiles only when Phoenix.Component is loaded (spec/10 §1.1, D-45, D-85).

Summary

Functions

Whether a key's enum is chosen by its picture.

The inline SVG for one value of a drawn key, or nil for a key that is not drawn or a value it does not know.

The inline SVG of a control's icon — :eye and :eye_off for the layer toggle, :lock for a library layer and :lock_open for one unlocked from it (spec/14 §18.8), :inspect, :colour and :variables for the panel row, and a root's name (a string) for the node row (§18.13, #314) — in currentColor, 18px, hidden from readers since the control names itself.

Functions

drawn?(key)

@spec drawn?(atom()) :: boolean()

Whether a key's enum is chosen by its picture.

iex> Visualize.Chart.Builder.Glyphs.drawn?(:curve)
true

iex> Visualize.Chart.Builder.Glyphs.drawn?(:op)
false

glyph(key, value)

@spec glyph(atom(), atom()) :: String.t() | nil

The inline SVG for one value of a drawn key, or nil for a key that is not drawn or a value it does not know.

iex> Visualize.Chart.Builder.Glyphs.glyph(:stroke_linecap, :round) =~ ~s|stroke-linecap="round"|
true

iex> Visualize.Chart.Builder.Glyphs.glyph(:op, :sum)
nil

icon(name)

@spec icon(atom() | String.t()) :: String.t()

The inline SVG of a control's icon — :eye and :eye_off for the layer toggle, :lock for a library layer and :lock_open for one unlocked from it (spec/14 §18.8), :inspect, :colour and :variables for the panel row, and a root's name (a string) for the node row (§18.13, #314) — in currentColor, 18px, hidden from readers since the control names itself.

iex> Visualize.Chart.Builder.Glyphs.icon(:lock) =~ ~s|<rect x="5" y="11"|
true