jxxcarlson/elm-tree-builder/5.0.0

NOTE: the latest version is 7.0.0

Tree.Svg

Helper functions for rendering trees:

import Tree.Build
import Tree.Render


-- Build the tree from text
tree =
    Tree.Build.fromString "?" .content "1\n 2\n 3\n 4\n"


-- Build the graph
graph =
    Result.map (Tree.Render.toGraph preferences identity)
      tree |> Result.withDefault []




-- Render the graph.  The first argument is the label style.
Tree.Svg.render NoLabel (Tree.Svg.transform 280 100 60 60 0.5 graph)
= NoLabel
| FullLabel
| FirstWord
render : LabelStyle -> Graph -> List (Svg msg)

Render a graph to SVG

transform : Float -> Float -> Float -> Float -> Float -> Graph -> Graph

Transform: shift by dx, dy and rescale by sx,sy,sr where the arguments are dx, dy, sx, sy, sr, graph