Linux lets you change the foreground and background colors of the terminal. You can use this to create QR codes.
#!/usr/bin/ruby -w
require 'rubygems'
require 'rqrcode'
margin = 1
qr = RQRCode::QRCode.new(ARGV[0], :size => 4, :level => :h )
res = ""
size = qr.modules.size + margin * 2
white = "33[5;37;47m "
black = "33[0;34;40m "
size.times do |x|
size.times do |y|
if x < margin || y < margin || x >= size - margin || y >= size - margin
res += white
elsif qr.is_dark(x - margin,y - margin)
res += black
else
res += white
end
end
res += "33[0m\n"
end
puts res
Advertisement