#!/usr/bin/perl # resample2.pl - Don Yang (uguu.org) # # Apply ghetto anti-aliasing to incoming text. # # 04/26/08 use strict; my @dict = ( ' ', # .... ',', # ...1 '.', # ..2. 'o', # ..21 '`', # .4.. ')', # .4.1 '0', # .42. 'd', # .421 "'", # 8... '0', # 8..1 '(', # 8.2. 'b', # 8.21 '"', # 84.. '9', # 84.1 'P', # 842. '8' # 8421 ); while(my $line1 = <>) { my $line2 = <>; chomp $line1; chomp $line2; # Pad the two lines so that they are equal in length, and contains # even number of characters if( length($line1) > length($line2) ) { $line1 .= ' ' if( length($line1) & 1 ); $line2 .= ' ' x (length($line1) - length($line2)); } else { $line2 .= ' ' if( length($line2) & 1 ); $line1 .= ' ' x (length($line2) - length($line1)); } # Convert pixels for(my $i = 0; $i < length($line1); $i += 2) { my $block = (substr($line1, $i, 1) =~ /\S/ ? 8 : 0) + (substr($line1, $i + 1, 1) =~ /\S/ ? 4 : 0) + (substr($line2, $i, 1) =~ /\S/ ? 2 : 0) + (substr($line2, $i + 1, 1) =~ /\S/ ? 1 : 0); print $dict[$block]; } print "\n"; }