Skip to content

Instantly share code, notes, and snippets.

@eregon
Created January 21, 2012 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eregon/3cda65f5513ee48774f9 to your computer and use it in GitHub Desktop.
Save eregon/3cda65f5513ee48774f9 to your computer and use it in GitHub Desktop.
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