Hylograph.Flow.Render.Route
- Package
- purescript-hylograph-flow-render
- Repository
- afcondon/purescript-hylograph-flow-render
The line an edge is drawn along, as data.
In 0.2 a placed edge held an SVG path string. A string can be drawn and
nothing else: to measure an edge an earlier layout trial had to
parse the string back, and a second layout engine had to print its
routes as strings only for them to be read again. Here the route is a
value, the string is derived from it (svgPath), and so are the points
it is measured along (flatten).
THE THREE ROUTES. Route is closed, and has exactly the routes of the
three engines this renderer is built to take. None is there for an
engine nobody has.
Ribbon, the Sankey layout's: a centre line of straight and cubic pieces, and abreadth, the room the edge takes on the side of each node it touches (its two attachment spans are the centre line's two ends, half the breadth either way across the flow). The Sankey layout's ribbons are as broad at one end as at the other, so the width profile is one number; an engine that tapers one would need a profile here, and none of the three does.inksays how the ribbon is drawn: aBandas broad as it is, or aHairlinedown its middle. It is an ADT and not a second number because a stroke beside a breadth is two numbers that can disagree, and in a band they are one.Polyline,layered-layout's: straight legs from point to point, and its line jumps (where it hops over an edge it crosses). That the bends are right angles is not in the type: that engine's routes through nested groups are joined at the group's boundary and may slant by a pixel or two there, so right angles are a promise an engine makes and a law checks (RoutesOrthogonal), not a constructor.Spline, Graphviz dot's (Stemma): cubic Bézier pieces end to end.
NO ROUTE WITHOUT A LINE. Each constructor has a first point and at least
one more (a NonEmptyArray of pieces, or a to), so an edge that is
placed has somewhere to be drawn; an engine that cannot route an edge
leaves the edge out, and the law that every edge is placed says so. The
trial's unrouted measure counted polylines of fewer than two points;
there is no such value now.
MEASURING. flatten is the one rule by which every route becomes
straight pieces: a straight piece is its two ends, a cubic piece is
curveSteps (12) straight pieces, and a cubic whose four points lie on
one line is one. It is the trial's rule (it read the same pieces back
from the path string), kept so that its figures stand. A polyline's
jumps are ink, not geometry: they are drawn and not measured.
#curveSteps Source
curveSteps :: IntStraight pieces to a cubic piece.
#svgPath Source
svgPath :: Route -> StringA route as the d of an SVG path: absolute M, L and C, and for a
polyline's jumps A. A jump is drawn as a half circle of hopRadius
where it lies on a leg with that much of the leg clear on either side
of it (of the leg's ends and of the jump before); a jump with less room
is passed straight through.