Skip to content

Instantly share code, notes, and snippets.

@eregon eregon/letters.rb Secret
Created Jan 21, 2012

Embed
What would you like to do?
letters = [?!,?.]+(?A..?Z).to_a
characters = `figlet -f banner -w 1000 #{letters.join}`
characters_colums = characters.lines.map { |line| line.chomp.chars.map { |c| c == '#' } }.transpose
bitmaps = characters_colums.chunk(&:none?).reject(&:first).map(&:last).map(&:transpose)
bitmaps.each do |bitmap|
bitmap.map! { |row|
l = (8-row.size)/2
[false]*l + row + [false]*(8-row.size-l)
}
end
# encode them
print bitmaps.map { |bitmap|
bitmap.reduce(:concat).each_with_index.inject(0) { |s,(e,i)| e ? s | 1<<i : s }
}.pack('Q<*')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.