A line through points (spec/07 §3), copied from visualize's Visualize.Shape.Line.
new/0 reads tuple elements 0 and 1 as x and y, so {x, y} tuples need no
configuration:
iex> alias Macaw.Draw.Shape.Line
iex> Line.new() |> Line.generate([{0, 0}, {10, 5}, {20, 2}])
"M0,0L10,5L20,2"generate_path/2 splits the data into defined runs (§1.2: a falsy defined and a
coordinate that is no number each break the line), draws each run through the curve as
its own subpath, and concatenates them in data order; no run of two points is the empty
path. A layer whose pixels are columns hands runs_path/2 its runs of {x, y} points
instead, and reads no accessor (§1.4).
An accessor is a 1-arity function, a field name read from a map datum by spelling (:v
finds "v" and the other way round, as Macaw.Data.Table.get/2 reads it), or a
numeric constant (§1.1). A generator takes a list of data; any other term is
{:error, [{[], {:type, :list}}]}.
Summary
Types
An accessor: a 1-arity function, a field name, or a numeric constant (§1.1).
A refusal: faults with their paths.
Functions
curve(line, type, []).
Sets the curve type (§5) and its options: {:ok, line}, or {:error, faults} for an
unknown type ({[], {:unknown, :curve, spelling}}) or an option of the wrong type.
As curve/3, the line itself, raising Macaw.Draw.Error with its faults.
Sets the defined predicate (§1.2), a 1-arity function; nil clears it.
The SVG path data of generate_path/2.
The line's Macaw.Draw.IR.Path: one subpath per defined run of two or more points, each
through the curve, in data order (§3).
A line reading tuple elements 0 and 1.
The path of runs already read (§1.4): each run a list of {x, y} points drawn through
the curve as its own subpath, in order, as generate_path/2 draws a run of defined data.
A point that is no pair of numbers is {[1, run, i], {:type, :point}}.
Sets the x accessor: a function, a field, or a number.
Sets the y accessor: a function, a field, or a number.
Types
An accessor: a 1-arity function, a field name, or a numeric constant (§1.1).
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
curve(line, type, []).
Sets the curve type (§5) and its options: {:ok, line}, or {:error, faults} for an
unknown type ({[], {:unknown, :curve, spelling}}) or an option of the wrong type.
As curve/3, the line itself, raising Macaw.Draw.Error with its faults.
Sets the defined predicate (§1.2), a 1-arity function; nil clears it.
The SVG path data of generate_path/2.
@spec generate_path(t(), [term()]) :: Macaw.Draw.IR.Path.t() | error()
The line's Macaw.Draw.IR.Path: one subpath per defined run of two or more points, each
through the curve, in data order (§3).
@spec new() :: t()
A line reading tuple elements 0 and 1.
@spec runs_path(t(), [[{number(), number()}]]) :: Macaw.Draw.IR.Path.t() | error()
The path of runs already read (§1.4): each run a list of {x, y} points drawn through
the curve as its own subpath, in order, as generate_path/2 draws a run of defined data.
A point that is no pair of numbers is {[1, run, i], {:type, :point}}.
Sets the x accessor: a function, a field, or a number.
Sets the y accessor: a function, a field, or a number.