summaryrefslogtreecommitdiff
path: root/script/qr-color.pl
diff options
context:
space:
mode:
Diffstat (limited to 'script/qr-color.pl')
-rw-r--r--script/qr-color.pl116
1 files changed, 106 insertions, 10 deletions
diff --git a/script/qr-color.pl b/script/qr-color.pl
index 8d78a2f..5841e0f 100644
--- a/script/qr-color.pl
+++ b/script/qr-color.pl
@@ -1,15 +1,21 @@
#!/usr/bin/perl
+use utf8;
use strict;
use warnings;
use Text::QRCode;
use TextPrinter::ColourGrid;
use TextPrinter::StarGrid;
use GridFiller;
-use Path::Class;
+use GridFiller::Scaler;
+use feature 'say';
+use open ':std',':locale';
use Log::Log4perl qw(:easy);
-Log::Log4perl->easy_init($DEBUG);
+Log::Log4perl->easy_init($INFO);
-my $data='MECARD:N:Ceccarelli,Gianni;TEL:+447564023056;EMAIL:dakkar@thenautilus.net;URL:http://www.thenautilus.net/contacts/;NICKNAME:dakkar;;';
+binmode DATA,':utf8';
+
+my $data = do { local $/="\n__WORDS__\n";my $x=<DATA>;chomp $x;$x };
+my @words = <DATA>;chomp @words;
my $qr=Text::QRCode->new(
level=>'H',
@@ -18,15 +24,105 @@ my $qr=Text::QRCode->new(
my $arr=$qr->plot($data);
-my @words = grep { length($_) > 2 }
- file('/usr/share/dict/propernames')->slurp(chomp=>1);
-
-my $filler=GridFiller->new({words=>\@words,grid=>$arr});
+my $filler=GridFiller->new({
+ words=>\@words,
+ grid=> GridFiller::Scaler->scale($arr,2),
+});
-my $result = $filler->fill;
+my $result = $filler->fill({
+ mode => 'longest',
+ chooser => 'Smarter',
+});
TextPrinter::ColourGrid->new->draw_whole($result->grid,1);
-print "\n\n";
+say '';
+say 'Leftovers:';
+say for @{$result->leftover_words};
-TextPrinter::StarGrid->new->draw_whole($arr,1);
+__DATA__
+MECARD:N:Ceccarelli,Gianni;TEL:+447564023056;EMAIL:dakkar@thenautilus.net;URL:http://www.thenautilus.net/contacts/;NICKNAME:dakkar;;
+__WORDS__
+Lois McMaster Bujold
+Kage Baker
+David Weber
+Robert Heinlein
+Douglas Adams
+Neal Stephenson
+Lewis Carrol
+Terry Pratchett
+Jorge Luis Borges
+Frank Herbert
+Alessandro Bergonzoni
+Stefano Benni
+Jules Verne
+Neil Gaiman
+H.G. Wells
+Isaac Asimov
+Arthur C. Clarke
+Philip K. Dick
+JRR Tolkien
+Ed Wood
+Tim Burton
+Monty Python
+Terry Gilliam
+Orson Welles
+Peter Greenaway
+David Cronenberg
+Stanley Kubrick
+Joss Whedon
+Quentin Tarantino
+Mel Brooks
+MIYAZAKI Hayao
+OSHII Mamoru
+ANNO Hideaki
+Alan Moore
+KITOH Mohiro
+TEZUKA Osamu
+YUKI Masami
+URASAWA Naoki
+YUKINOBU Hoshino
+yoshitoshi ABe
+SHIROW Masamune
+Amanda Palmer
+Marian Call
+Jonathan Coulton
+The Flaming Lips
+The Pillows
+Nightwish
+Stefano Nosei
+Jethro Tull
+KANNO Yoko
+Franco Battiato
+Enya
+Helloween
+Mike Oldfield
+Alan Parsons Project
+Emerson, Lake & Palmer
+Fabrizio De André
+Kenji Kawai
+David Bowie
+Girl Genius
+Gunnerkrigg Court
+Cyrano de Bergerac
+Watership Down
+RHPS
+Thunderbirds
+Doctor Who
+The Twilight Zone
+Blade Runner
+Forbidden Planet
+Cowboy Bebop
+FLCL
+Gundam
+Macross
+Fushigi no umi no Nadia
+SUZUMIYA Haruhi
+Cutey Honey
+Dennou Coil
+Haibane Renmei
+Star Trek
+D&D
+Go
+Shogi
+Perl