Skip to content

Instantly share code, notes, and snippets.

@jonashaag
Created March 18, 2014 15:36
Show Gist options
  • Save jonashaag/9622563 to your computer and use it in GitHub Desktop.
Save jonashaag/9622563 to your computer and use it in GitHub Desktop.
import Data.Tree
import Diagrams.Prelude
import Diagrams.TwoD.Layout.Tree
import Diagrams.Backend.SVG.CmdLine
t1 = Node 'A' [Node 'B' (map lf "CDE"), Node 'F' [Node 'G' (map lf "HIJ")]]
where lf x = Node x []
exampleSymmTree :: Diagram B R2
exampleSymmTree = foldl1 (|||) (map renderWithSep [0.5..5])
where renderWithSep sep = renderTree ((<> circle 1 # fc white) . text . (:[]))
(~~)
(symmLayout' (with & slHSep .~ sep & slVSep .~ sep) t1)
# lw 0.03
# centerXY # pad 1.1
main = mainWith exampleSymmTree
import Data.Tree
import Diagrams.Prelude
import Diagrams.TwoD.Layout.Tree
import Diagrams.Backend.SVG.CmdLine
t1 = Node 'A' [Node 'B' (map lf "CDE"), Node 'F' [Node 'G' (map lf "HIJ")]]
where lf x = Node x []
exampleSymmTree :: Diagram B R2
exampleSymmTree = foldl1 (|||) (map renderWithSep [0.5..5])
where renderWithSep sep = renderTree ((<> circle 1 # fc white) . text . (:[]))
(~~)
(symmLayout' (with & slHSep .~ sep & slVSep .~ sep) t1)
# lw 0.03
# centerXY # pad 1.1
=== text (show sep) # scale 2
main = mainWith exampleSymmTree
import Data.Tree
import Diagrams.Prelude
import Diagrams.TwoD.Layout.Tree
import Diagrams.Backend.SVG.CmdLine
t1 = Node 'A' [Node 'B' (map lf "CDE"), Node 'F' [Node 'G' (map lf "HIJ")]]
where lf x = Node x []
exampleSymmTree :: Diagram B R2
exampleSymmTree = foldl1 (|||) (map renderWithSep [0.5..5])
where renderWithSep sep = text (show sep) # scale 2
=== renderTree ((<> circle 1 # fc white) . text . (:[]))
(~~)
(symmLayout' (with & slHSep .~ sep & slVSep .~ sep) t1)
# lw 0.03
# centerXY # pad 1.1
main = mainWith exampleSymmTree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment