A simple script, module or app that generates a list of plots and draws simple text representation of arbitrary curves; OR the acknowledgement that no such thing exists and I have to write it myself.
The Rationale:The purpose is for a quick-and-dirty way to sketch curves and see what they look like in text before sending the plot points off to another program, without having to use any sophisticated packages like GD or the like. Since the functionality is very simple, the question is whether someone has already written something like this that has support for a wide variety of quick-and-simple family of curves, as well as a way to quickly sketch them out in text.
An Example:
### GetTrigCurve($iLength,$iAmplitude,$fFreq,$sType);
my @aCurve = GetTrigCurve(30,48,100,'cos');
print GetPoints( [@aCurve] )
print DrawCurve( [@aCurve] );
__END__
0,3,12,24,36,45,47,44,34,22,10,2,0,4,14,26,38,46,47,42,32,20,8,1,0,5,16,28,40,46,47
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
###
Yes, CPAN was the first stop on this particular quest, however it seems the requested functionality is far too trivial, or the search effort wasn't up to snuff, as there does not appear to be anything on CPAN that quite fits the bill. Really all I am looking for is a group of standard functions like you can find with a msft Excel spreadsheet, that lets you plot out a few datapoints (like you can with a spreadsheet) all within the confines of perl.
YuckFrill
Example:
perl -e 'print "$_ " . sin($_ / 10) . "\n" for (1..64)' | graph.pl
#!/usr/bin/perl use strict; my ($WIDE) = @ARGV; $WIDE ||= 80; my (@list, $min, $max); my ($maxval, $maxkey); while (my $line =) { chomp $line; my ($key, $val) = split(' ', $line); if (defined($key) && defined($val)) { push (@list, { key => $key, val => $val}); if (!defined($min) || $val < $min) { $min = $val; } if (!defined($max) || $val > $max) { $max = $val; } if (!defined($maxkey) || length($key) > $maxkey) { $maxkey = length($key); } if (!defined($maxval) || length($val) > $maxval) { $maxval = length($val); } } } my $factor = ($max - $min) / ($WIDE - $maxkey - $maxval - 2); for my $i (@list) { printf STDOUT "%-*.*s %s $i->{val}\n", $maxkey, $maxkey, $i->{key}, '*' x (($i->{val} - $min) / $factor); }
perlmonks.org content © perlmonks.org and dimar, injunjoel, YuckFoo
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03