-
Notifications
You must be signed in to change notification settings - Fork 0
/
manmachine-curses
executable file
·60 lines (53 loc) · 1.22 KB
/
manmachine-curses
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
# Copyright (c) 2008 Vsevolod Kozlov <zaba@thorium.homeunix.org>
# License: Public Domain.
use strict;
my $word = shift // usage();
my $count = shift // usage();
my $delay = shift // usage();
my $vdelay = shift // ($delay / 10);
use Curses;
use Time::HiRes qw(sleep);
print_manmachine($word);
sub usage
{
print "$0 word count delay [ vdelay ]\n";
print "\tword\tWord to print\n";
print "\tcount\tHow many times to print the word in one row\n";
print "\tdelay\tHow long to sleep between printing rows\n";
print "\tvdelay\tHow long to sleep between vertical prints\n";
exit 1;
}
sub print_manmachine
{
my ($word) = @_;
initscr();
curs_set(0);
start_color();
init_pair(1, COLOR_RED, COLOR_BLACK);
my @letters = split //, $word;
for(my ($i, $j) = (0, scalar @letters-1); $i < scalar @letters; ++$i, --$j)
{
move($j,$i);
for(my$d=$count;$d--;)
{
printw($word);
printw(" " x (scalar @letters-1));
}
refresh();
sleep($delay);
}
for(my $i = 0; $i < scalar @letters; ++$i)
{
for(my$f=$count;$f--;)
{
move($i, (((scalar @letters)*2)-1)*($f+1)-(scalar @letters));
attron(COLOR_PAIR(1));
printw($letters[$i]);
attroff(COLOR_PAIR(1));
}
refresh();
sleep($vdelay);
}
endwin();
}