Skip to content

Instantly share code, notes, and snippets.

@sugyan
Created June 7, 2011 07:40
Show Gist options
  • Save sugyan/1011836 to your computer and use it in GitHub Desktop.
Save sugyan/1011836 to your computer and use it in GitHub Desktop.
npm xmas
#!/usr/bin/env perl
use strict;
use warnings;
use Encode 'encode_utf8';
my $s = ' ' . encode_utf8(pack 'U', 0x2605);
my $f = encode_utf8(pack 'U', 0xFF0F);
my $b = encode_utf8(pack 'U', 0xFF3C);
my $o = [ map { encode_utf8(pack 'U', $_) } (
0x0069, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
0x0020, 0x2E1B, 0x2042, 0x2E2E, 0x0026, 0x0040, 0xFF61,
) ];
my $oc = [ 21, 33, 34, 35, 36, 37 ];
my $l = pack 'U', 0x005e;
sub tree {
my ($H) = @_;
print("\n");
print(" " x $H);
print("\033[33m" . $s . "\n");
my $M = $H * 2 - 1;
for my $L (1 .. $H) {
my $O = $L * 2 - 2;
my $S = ($M - $O) / 2 + 1;
print(" " x $S);
print("\033[32m" . $f);
for (1 .. $O) {
print("\033[" . $oc->[ int(rand @$oc) ] . "m" . $o->[ int(rand @$o) ]);
}
print("\033[32m" . $b . "\n");
}
print(" ");
print("\033[32m" . $l) for 1 .. $H - 1;
print("| |");
print("\033[32m" . $l) for 1 .. $H - 1;
if ($H > 10) {
print("\n ");
print(" ") for 1 .. $H - 1;
print("| |");
print(" ") for 1 .. $H - 1;
}
print("\n\n");
}
tree(20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment