monitor.rb now uses real 24-bit-colors instead of ansi colors.

This commit is contained in:
Fabian Schlenz 2020-08-06 15:37:38 +00:00
parent 0ac4f9b181
commit a96f6c79e3

View File

@ -2,16 +2,6 @@
require 'websocket-eventmachine-client'
require 'pp'
def rgb2ansi(r, g, b)
if r==g && g==b
return 16 if r<8
return 231 if r>248
return (((r - 8) / 247.0) * 24).round + 232
end
return 16 + 36*(r/51.0).round + 6*(g/51.0).round + (b/51.0).round
end
IP = ARGV[0]
EFFECT = ARGV[1]
uri = "ws://#{IP}:80/ws"
@ -41,8 +31,7 @@ EM.run do
str += "|"
(0...width).each do |x|
r, g, b = *data.shift(3)
color_code = rgb2ansi(r, g, b)
str += "\033[48;5;#{color_code}m "
str += "\033[38;2;#{r};#{g};#{b}m●"
end
str += "\033[0m|\n"
end