INNER CODE UNIT · Ruby
ANSI_ESCAPE
busyloop/lolcat · lib/lolcat/lol.rb:30
ANSI_ESCAPE = /((?:\e(?:[ -\/]+.|[\]PX^_][^\a\e]*|\[[0-?]*.|.))*)(.?)/m
INCOMPLETE_ESCAPE = /\e(?:[ -\/]*|[\]PX^_][^\a\e]*|\[[0-?]*)$/
@os = 0
@paint_init = false
def self.rainbow(freq, i)
red = Math.sin(freq*i + 0) * 127 + 128
green = Math.sin(freq*i + 2*Math::PI/3) * 127 + 128
blue = Math.sin(freq*i + 4*Math::PI/3) * 127 + 128
"#%02X%02X%02X" % [ red, green, blue ]
end
def self.cat(fd, opts={})
@os = opts[:os]
print "\e[?25l" if opts[:animate]
while true do
buf = ''