Language::Homespring::Visulaise::GraphViz - A visual op-tree viewer for "Homespring"
use Language::Homespring; use Language::Homespring::Visualise::GraphViz; my $code = "bear hatchery Hello,. World ..\n powers"; my $hs = new Language::Homespring(); $hs->parse($code); my $vis = new Language::Homespring::Visualise::GraphViz({'interp' => $hs}); print $vis->do()->as_gif;
This module implements a viewer for Homespring op-trees, using the GraphViz program. You can now see the rivers that your code produces :)
new({'interp' => $hs})
Creates a new Language::Homespring::Visualise::GraphViz object. The single hash argument contains initialisation info. The only key currently required is 'interp', which should point to the Language::Homespring object you wish to visualise.
Language::Homespring::Visualise::GraphViz
Language::Homespring
Other optional keys are:
node_col
The background color to use for reserved word nodes. Specified in GraphViz format (#rrggbb is ok). Defaults to white.
spring_col
The background color to use for spring nodes. Specified in GraphViz format (#rrggbb is ok). Defaults to #c0c0ff (light blue).
fontname
The name of the font to use. Defaults to "Times".
Important: If the font file cannot be found (for "Times", "Times.ttf" must be in the font seach path - remember case sensitivity on unix etc.) then a built in font will be used, BUT the labels will not be centered in the nodes.
fontsize
The size of the font in points. Defaults to 12.
do()
Returns a GraphViz object, with all nodes and edges for the current state of the op-tree. You can then call standard GraphViz methods on this object such as as_gif() and as_png() to output an image.
GraphViz
The examples folder in this distribution contains an example script (example.pl) and three example GIFs. The GIFs are visual representations of the .hs files of the same name from the Language::Homespring distribution.
example.pl
Copyright (C) 2003 Cal Henderson <cal@iamcal.com>
perl
http://www.graphviz.org/
To install Language::Homespring::Visualise::GraphViz, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::Homespring::Visualise::GraphViz
CPAN shell
perl -MCPAN -e shell install Language::Homespring::Visualise::GraphViz
For more information on module installation, please visit the detailed CPAN module installation guide.