Skip to content

Commit

Permalink
Change 'radius' key to 'compradius' and 'inputradius'.
Browse files Browse the repository at this point in the history
Set their default values to 2 and 0, respectively.

As part of error checking, only draw endpoints if radii size > 0;

Documentation and code weren't matching when it came to color setting.
Corrected color use (hex triplets instead of names).
Refactored color handling and check for a monotone case.
Put in background-colored rect (both postscript and svg) within the diagram.

With radius split b/n comparator and input radius now, it also
made sense to split stroke_width b/n comparator and input line with too.

This in turn meant moving the text diagram settings to their own
hash and function, to avoid name collision with the graph settings.
  • Loading branch information
jgamble committed Mar 14, 2018
1 parent 5f3423f commit 60e3ed6
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 209 deletions.
34 changes: 34 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
Revision history for Perl extension Algorithm::Networksort.

2.10
Fri Feb 9 2018
- Keys 'radius' and 'stroke_width' of graphsettings() split
into two each for the input lines and the comparator lines,
becoming 'inputradius' and 'compradius', and 'inputline'
and 'compline'. Zero-width radii (indicating no circle at
all) for either line is possible, and the comparator lines
and circles may be a different widths than the input lines
and circles.
- The settings of the text version of diagrams are now set
with function textsettings(), as making graphsettings()
handle it all was ridiculous, not to mention the key
collisions with the changes above.
- Changed colorsettings(), which wasn't following the
documentation correctly.
- Check for "monotone" diagrams. If all the colors are
the same, just set the color once in the SVG or
EPS output instead of setting the color for each part
of the diagram. (If you want each color set even though
the colors are the same, simply set each part's color
in colorsettings(), then set 'foreground' to a different
color. Since 'foreground' is used as a default, it
won't change anything if there is nothing to default.)
- Encapsulated Postscript now can have color.
- Update the t/ and eg/ files to use the above changes.

Sun Jan 14 2018
- Test file best.t only skips networks of input size > 16
instead of all skipping all networks if AUTHOR_TESTING
isn't set.
Fri Jan 12 2018
- Added Designing Sorting Networks to the book list.
- Added David C. Van Voorhis's 16-input network (found in
Designing Sorting Networks) to Best.pm.
2.01
Wed Apr 20 2016
- Add nwsrt_title() to the list of default exported functions
Expand Down
31 changes: 29 additions & 2 deletions eg/eps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,50 @@
use strict;
use warnings;

#
# These are the default settings.
#
my %graphset = (
hz_margin => 18,
hz_sep => 12,
indent => 9,
inputline => 2,
inputradius => 2,
compline => 2,
compradius => 2,
vt_margin => 21,
vt_sep => 12,
);

my %colorset = (compbegin => undef,
compend => undef,
compline => undef,
inputbegin => undef,
inputend => undef,
inputline => undef,
foreground => undef,
background => undef,
);
my $alg = 'bosenelson';
my($nw, $best);

GetOptions('compbegin=s' => \$colorset{compbegin},
'compend=s' => \$colorset{compend},
'compline=s' => \$colorset{compline},
'ccompline=s' => \$colorset{compline},
'inputbegin=s' => \$colorset{inputbegin},
'inputend=s' => \$colorset{inputend},
'inputline=s'=> \$colorset{inputline},
'cinputline=s'=> \$colorset{inputline},
'foreground=s' => \$colorset{foreground},
'background=s' => \$colorset{background},
'hz_margin=i' => \$graphset{hz_margin},
'hz_sep=i' => \$graphset{hz_sep},
'indent=i' => \$graphset{indent},
'inputradius=i' => \$graphset{inputradius},
'compradius=i' => \$graphset{compradius},
'inputline=i' => \$graphset{inputline},
'compline=i' => \$graphset{compline},
'vt_margin=i' => \$graphset{vt_margin},
'vt_sep=i' => \$graphset{vt_sep},
'algorithm=s' => \$alg,
'best=s' => \$best,
);
Expand All @@ -39,6 +65,7 @@
}

$nw->colorsettings(%colorset);
$nw->graphsettings(%graphset);

print $nw->graph_eps();

Expand Down
16 changes: 10 additions & 6 deletions eg/svg.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
#
# These are the default settings.
#
my %graphset = (hz_margin => 18,
my %graphset = (
hz_margin => 18,
hz_sep => 12,
indent => 9,
radius => 2,
stroke_width => 2,
inputline => 2,
inputradius => 2,
compline => 2,
compradius => 2,
vt_margin => 21,
vt_sep => 12,
);
Expand Down Expand Up @@ -40,8 +43,10 @@
'hz_margin=i' => \$graphset{hz_margin},
'hz_sep=i' => \$graphset{hz_sep},
'indent=i' => \$graphset{indent},
'radius=i' => \$graphset{radius},
'stroke_width=i' => \$graphset{stroke_width},
'inputradius=i' => \$graphset{inputradius},
'compradius=i' => \$graphset{compradius},
'inputline=i' => \$graphset{inputline},
'compline=i' => \$graphset{compline},
'vt_margin=i' => \$graphset{vt_margin},
'vt_sep=i' => \$graphset{vt_sep},
'algorithm=s' => \$alg,
Expand All @@ -59,7 +64,6 @@
$nw = nwsrt(inputs => $inputs, algorithm => $alg);
}


$nw->colorsettings(%colorset);
$nw->graphsettings(%graphset);

Expand Down
2 changes: 1 addition & 1 deletion eg/text.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

$def_txtset{inputend} .= "\n" if (defined $txtset{inputend});

$nw->graphsettings(%def_txtset);
$nw->textsettings(%def_txtset);

print $nw->graph_text() . "\t" . $nw->title() . "\n";

Expand Down
Loading

0 comments on commit 60e3ed6

Please sign in to comment.