#!/usr/bin/perl -w use strict; if( $#ARGV != 0 ) { die "$0 \n"; } my $line_count = $ARGV[0]; my $pi = atan2(0, -1); my @buffer = (); for(my $i = 0; $i < 40; $i++) { push @buffer, (("X" x 79) . "\n"); } my $char = 0; my $last_x = 40; my $last_y = 80; for(; $line_count > 0; $line_count--) { push @buffer, (("X" x 79) . "\n"); # Generate star my $cx = rand(70) + 5; my $distance = sqrt(($cx - $last_x) * ($cx - $last_x) + $last_y * $last_y); if( $last_y > 30 && $distance > 40 ) { my $size0 = 1 + rand(2); my $size1 = 12 - $size0 + rand(8); my $phase = rand(2 * $pi); for(my $ta = 0; $ta < 10 * $pi; $ta += 0.05) { my $r = $size0 + $size1 + $size1 * 0.5 * sin($ta + $phase); for(my $tr = 0; $tr < $r; $tr += 0.1) { my $x = $cx + $tr * cos($ta / 5); my $y = $#buffer - 20 + $tr * sin($ta / 5) * 0.5; $y = int($y + 0.5); $x = int($x + 0.5); if( $x >= 0 && $x < length($buffer[$y]) ) { substr($buffer[int($y + 0.5)], int($x + 0.5), 1) = ' '; } } } $last_x = $cx; $last_y = 0; } else { $last_y += 2; } # Output text following template my $template = shift @buffer; foreach my $c (unpack 'C*', $template) { $c = chr($c); if( $c =~ /\s/s ) { print $c; } else { print chr($char + ord('a')); $char = ($char + 1) % 26; } } }