#!/usr/bin/perl -w
use strict;
use POSIX;
my ($cols, $rows) = do {
use Term::ReadKey;
GetTerminalSize();
};
my $termios = POSIX::Termios->new();
$termios->getattr(fileno(STDIN));
my $terminal = do {
require Term::Cap;
Tgetent Term::Cap { TERM => undef, OSPEED => $termios->getospeed };
};
sub drawbox {
my ($x1, $y1, $x2, $y2) = (shift, shift, shift, shift);
($x1, $x2) = $x1 < $x2 ? ($x1, $x2) : ($x2, $x1);
($y1, $y2) = $y1 < $y2 ? ($y1, $y2) : ($y2, $y1);
for my $y ($y1, $y2) {
$terminal->Tgoto("cm", $x1, $y, \*STDOUT);
print "#" x ($x2 - $x1);
}
for my $y ($y1..$y2) {
$terminal->Tgoto("cm", $x1, $y, \*STDOUT);
print "#";
$terminal->Tgoto("cm", $x2, $y, \*STDOUT);
print "#";
}
}
$terminal->Tputs("ho", 0, \*STDOUT);
$terminal->Tputs("cd", 0, \*STDOUT);
my ($vertctr, $horzctr) = (int $rows / 2, int $cols / 2);
for (1 .. ($cols / 20 - 1)) {
my ($width, $heigt) = ($_ * 10, int $_ * 10 * $rows / $cols);
my ($x1, $y1, $x2, $y2) = (
$horzctr - $width,
$vertctr - $heigt,
$horzctr + $width,
$vertctr + $heigt
);
drawbox($x1, $y1, $x2, $y2);
}
print "\n";