Created
April 23, 2012 12:22
-
-
Save shoorick/2470601 to your computer and use it in GitHub Desktop.
Print color stripes with HTML colouring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
=head1 USAGE | |
./word-color.pl | |
=head1 DESCRIPTION | |
Print color stripes. See L<http://habrahabr.ru/post/142570/> | |
=cut | |
use strict; | |
use warnings; | |
use Text::Aspell; | |
my $speller = Text::Aspell->new; | |
die unless $speller; | |
# Set some options | |
$speller->set_option('lang','en_US'); | |
$speller->set_option('sug-mode','fast'); | |
for my $color ( 0x000 .. 0xFFF ) { | |
my $word = sprintf '%03X', $color; | |
$word =~ tr [012567] | |
[OIZSGT]; | |
next if $word =~ /\d/; | |
next unless $speller->check( lc $word ); | |
printf | |
qq{<font color="#%06x">████████████████</font> #%03X → %s\n}, | |
($color & 0xF00) * 0x1100 + ($color & 0xF0) * 0x110 + ($color & 0xF) * 0x11, | |
$color, $word; | |
} | |
=head1 AUTHOR | |
Alexander Sapozhnikov | |
L<< http://shoorick.ru/ >> E<lt>L<shoorick@cpan.org>E<gt> | |
=head1 COMPANY | |
South Ural State University L<< http://susu.ac.ru/ >> | |
=cut | |
# VERSION: 1.0 | |
# CREATED: 23.04.2012 17:55:55 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment