module Branding::ANSI
Constants
- ATTRS
- BGCOLORS
- FGCOLORS
- SHADERS
2580 - 259F
Public Instance Methods
bg(r, g, b)
click to toggle source
# File lib/branding/ansi.rb, line 15 def bg(r, g, b) BGCOLORS[rgb_offset(r, g, b)] end
clamped(uint32)
click to toggle source
we probably shouldn't be passing in non-ints
# File lib/branding/ansi.rb, line 70 def clamped(uint32) return [0, 0, 0] unless uint32.is_a?(Integer) r = (uint32 & 0xff000000) >> 24 g = (uint32 & 0x00ff0000) >> 16 b = (uint32 & 0x0000ff00) >> 8 scale_color(r) & scale_color(g) & scale_color(b) end
clear()
click to toggle source
# File lib/branding/ansi.rb, line 23 def clear end
down()
click to toggle source
# File lib/branding/ansi.rb, line 29 def down end
fg(r, g, b)
click to toggle source
# File lib/branding/ansi.rb, line 11 def fg(r, g, b) FGCOLORS[rgb_offset(r, g, b)] end
left()
click to toggle source
# File lib/branding/ansi.rb, line 32 def left end
reset()
click to toggle source
# File lib/branding/ansi.rb, line 19 def reset ATTRS[0] end
restore_cursor()
click to toggle source
# File lib/branding/ansi.rb, line 42 def restore_cursor :"\e[u" end
rgb_offset(r, g, b)
click to toggle source
0x10-0xE7: 6 × 6 × 6 = 216 colors
# File lib/branding/ansi.rb, line 47 def rgb_offset(r, g, b) 16 + (36 * scale_color(r)) + (6 * scale_color(g)) + scale_color(b) end
right()
click to toggle source
# File lib/branding/ansi.rb, line 35 def right end
save_cursor()
click to toggle source
# File lib/branding/ansi.rb, line 38 def save_cursor :"\e[s" end
scale_color(uint8)
click to toggle source
scale an 8bit number to 0-5 5*51==255
# File lib/branding/ansi.rb, line 54 def scale_color(uint8) (uint8 / 51.0).round end
uint32_to_rgb(uint32)
click to toggle source
we probably shouldn't be passing in non-ints
# File lib/branding/ansi.rb, line 59 def uint32_to_rgb(uint32) return [0, 0, 0] unless uint32.is_a?(Integer) r = (uint32 & 0xff000000) >> 24 g = (uint32 & 0x00ff0000) >> 16 b = (uint32 & 0x0000ff00) >> 8 [r, g, b] end
up()
click to toggle source
# File lib/branding/ansi.rb, line 26 def up end