A parent-child link's path (spec/08 §3.4): a curve, an elbow or a line from the parent's position to the child's, vertical or horizontal.
The positions are the layout's own in either orientation; only the path is oriented, so
size: {height, width} with :horizontal is a left-to-right tree:
shape | :vertical | :horizontal |
|---|---|---|
:curve | M x0,y0 C x0,ym x1,ym x1,y1, ym the mid-height | M y0,x0 C ym,x0 ym,x1 y1,x1 |
:elbow | M x0,y0 H x1 V y1 | M y0,x0 V x1 H y1 |
:line | M x0,y0 L x1,y1 | M y0,x0 L y1,x1 |
iex> path = Macaw.Draw.Layout.Links.path(:elbow, :vertical, {0, 0}, {10, 20})
iex> path.commands
[{:M, 0, 0}, {:H, 10}, {:V, 20}]A pack's links are always the straight line between the centers. This is visualize's
Visualize.Chart.Transform.Layout link_path/7 (#127, D-70), answering an IR path.
radial/4 is a radial tree's link (spec/08 §15.3), in polar positions about a center.
Summary
Functions
The link orientations: [:vertical, :horizontal].
The path from {x0, y0}, the parent's position, to {x1, y1}, the child's, in shape
and orientation, each an atom or the string of its spelling (§3.4). An unknown shape
is {[], {:unknown, :shape, shape}}, an unknown orientation
{[1], {:unknown, :orientation, orientation}}, a position that is not two numbers
{[n], {:type, :point}}.
A radial link from the parent at {a0, r0} to the child at {a1, r1}, angles in radians
clockwise from 12 o'clock about center (spec/08 §15.3)
The link shapes: [:curve, :elbow, :line].
Types
Functions
@spec orientations() :: [orientation()]
The link orientations: [:vertical, :horizontal].
@spec path( shape() | String.t(), orientation() | String.t(), {number(), number()}, {number(), number()} ) :: Macaw.Draw.IR.Path.t() | Macaw.Draw.Layout.error()
The path from {x0, y0}, the parent's position, to {x1, y1}, the child's, in shape
and orientation, each an atom or the string of its spelling (§3.4). An unknown shape
is {[], {:unknown, :shape, shape}}, an unknown orientation
{[1], {:unknown, :orientation, orientation}}, a position that is not two numbers
{[n], {:type, :point}}.
@spec radial( shape() | String.t(), {number(), number()}, {number(), number()}, {number(), number()} ) :: Macaw.Draw.IR.Path.t() | Macaw.Draw.Layout.error()
A radial link from the parent at {a0, r0} to the child at {a1, r1}, angles in radians
clockwise from 12 o'clock about center (spec/08 §15.3):
:curve: d3'slinkRadial, a cubic with control points at the mid radius(r0 + r1) / 2, at the parent's angle and at the child's;:elbow: an arc at the parent's radius from its angle to the child's, the shorter way, then the radial line out to the child;:line: the straight segment.
An unknown shape is {[], {:unknown, :shape, shape}}, a position or center that is not
two numbers {[n], {:type, :point}}.
iex> path = Macaw.Draw.Layout.Links.radial(:line, {0, 0}, {0, 10}, {5, 5})
iex> path.commands
[{:M, 5.0, 5.0}, {:L, 5.0, -5.0}]
@spec shapes() :: [shape()]
The link shapes: [:curve, :elbow, :line].