#45 Laying Out the Graph

You have the basic information about the regular expression. The next step is to lay things out. The size.pm module has two functions: it decides how big each element of the graph is and it decides where each element goes.

The Code

 1 use strict; 2 use warnings; 3 4 package size; 5 require Exporter; 6 7 use vars qw/@ISA @EXPORT format_re/; 8 9 @ISA = qw/Exporter/; 10 @EXPORT = qw/convert_re &BOX_FONT_SIZE 11 &X_CHAR_SIZE &X_MARGIN &Y_NODE_SIZE 12 &X_MARGIN &Y_MARGIN &MARGIN 13 &X_NODE_SIZE Y_NODE_SIZE 14 &X_BRANCH_MARGIN &Y_BRANCH_MARGIN 15 &X_TEXT_OFFSET &Y_TEXT_OFFSET 16 @format_re layout_array &BOX_MARGIN/; 17 18 # 19 # Constants that control the layout 20 # 21 # Margin around the graph 22 use constant MARGIN ...

Get Wicked Cool Perl Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.