2 # vim:ts=4:sw=4:expandtab
3 # renders the layout tree using asymptote
12 my $i3 = i3("/tmp/nestedcons");
14 my $tree = $i3->get_tree->recv;
16 my $tmp = File::Temp->new(UNLINK => 0, SUFFIX => '.asy');
18 say $tmp "import drawtree;";
20 say $tmp "treeLevelStep = 2cm;";
23 my ($n, $parent) = @_;
25 my $o = ($n->{orientation} eq 'none' ? "u" : ($n->{orientation} eq 'horizontal' ? "h" : "v"));
26 my $w = (defined($n->{window}) ? $n->{window} : "N");
29 my $name = "($na, $o, $w)";
31 print $tmp "TreeNode n" . $n->{id} . " = makeNode(";
33 print $tmp "n" . $parent->{id} . ", " if defined($parent);
34 print $tmp "\"" . $name . "\");\n";
36 dump_node($_, $n) for @{$n->{nodes}};
40 say $tmp "draw(n" . $tree->{id} . ", (0, 0));";
45 system("cd /tmp && asy $tmp && gv $rep && rm $rep");