A closed area between two edges (spec/07 §4), copied from visualize's
Visualize.Shape.Area.
new/0 reads x from tuple element 0, y1 from element 1, and sets the baseline y0
to the constant 0:
iex> alias Macaw.Draw.Shape.Area
iex> Area.new() |> Area.generate([{0, 0}, {10, 5}])
"M0,0L10,5L10,0L0,0Z"The effective accessors are x0 || x, x1 || x, y0 || y and y1 || y; x/2 sets
x, x0 and x1 together and y/2 sets y, y0 and y1 together, so y/2 after
new/0 makes the area zero-height. Each defined run of two or more points (§1.2) is one
closed ring: the top edge (x1, y1) forward, a line to the bottom edge (x0, y0)
reversed, both through the same curve, then Z.
runs_path/2 takes runs already read, each a list of {{x1, y1}, {x0, y0}} top and
bottom pairs (§1.4), and parts/3 cuts each run's ring in two along a boundary without
changing its curve (visualize D-274).
Summary
Types
A refusal: faults with their paths.
A run's points as runs_path/2 takes them: {{x1, y1}, {x0, y0}}, top and bottom.
Functions
curve(area, type, []).
Sets the curve of both edges and its options: {:ok, area}, or {:error, faults} for
an unknown type or an option of the wrong type (§5.1).
As curve/3, the area 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 the closed area.
The closed Macaw.Draw.IR.Path: one ring per defined run of two or more points.
An area with x from tuple element 0, y1 from element 1 and the baseline y0 = 0.
The rings of runs_path/2 in two parts, {settled, provisional} (§4; visualize D-274).
The path of runs already read (§1.4): each run a list of {{x1, y1}, {x0, y0}} pairs
made one closed ring, in order, as generate_path/2 makes a run of defined data.
Sets the bottom edge's x accessor.
Sets the top edge's x accessor.
Sets x, x0 and x1 together.
Sets the bottom edge's (the baseline's) y accessor.
Sets the top edge's y accessor.
Sets y, y0 and y1 together: the area is then zero-height.
Types
@type accessor() :: Macaw.Draw.Shape.Line.accessor()
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
A run's points as runs_path/2 takes them: {{x1, y1}, {x0, y0}}, top and bottom.
@type t() :: %Macaw.Draw.Shape.Area{ curve: Macaw.Draw.Shape.Curve.curve_type(), curve_opts: keyword(), defined: (term() -> term()) | nil, x: (term() -> term()) | nil, x0: (term() -> term()) | nil, x1: (term() -> term()) | nil, y: (term() -> term()) | nil, y0: (term() -> term()) | nil, y1: (term() -> term()) | nil }
Functions
curve(area, type, []).
Sets the curve of both edges and its options: {:ok, area}, or {:error, faults} for
an unknown type or an option of the wrong type (§5.1).
As curve/3, the area 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 the closed area.
@spec generate_path(t(), [term()]) :: Macaw.Draw.IR.Path.t() | error()
The closed Macaw.Draw.IR.Path: one ring per defined run of two or more points.
@spec new() :: t()
An area with x from tuple element 0, y1 from element 1 and the baseline y0 = 0.
@spec parts(t(), [[pair()]], (list() -> {list(), list()})) :: {Macaw.Draw.IR.Path.t(), Macaw.Draw.IR.Path.t()} | error()
The rings of runs_path/2 in two parts, {settled, provisional} (§4; visualize D-274).
cut is a 1-arity function from one edge's commands to {settled, provisional} command
lists. Each run's edges are generated whole, the top forward and the bottom reversed,
then cut: both wholly provisional makes the run's ring provisional; both cut into two
non-empty parts closes the settled heads into one ring and the provisional tails into
another; anything else keeps the whole ring settled.
@spec runs_path(t(), [[pair()]]) :: Macaw.Draw.IR.Path.t() | error()
The path of runs already read (§1.4): each run a list of {{x1, y1}, {x0, y0}} pairs
made one closed ring, in order, as generate_path/2 makes a run of defined data.
Sets the bottom edge's x accessor.
Sets the top edge's x accessor.
Sets x, x0 and x1 together.
Sets the bottom edge's (the baseline's) y accessor.
Sets the top edge's y accessor.
Sets y, y0 and y1 together: the area is then zero-height.