colors are now fixed (as in, not random)

This commit is contained in:
Christoffer Müller Madsen 2017-05-23 00:09:29 +02:00
parent 96e31c2479
commit 09e8aeb5c0

23
plot.rb
View File

@ -4,7 +4,10 @@ load 'config.rb'
users = USERNAMES users = USERNAMES
log_dir = LOG_DIR log_dir = LOG_DIR
colors = {} colors = {"christoffermadsen" => "1d6a6f",
"jmaa" => "9db512",
"jacob" => "e01476",
"alexander" => "00c0c7"}
def rand_color def rand_color
"%06x" % (rand * 0xffffff) "%06x" % (rand * 0xffffff)
@ -16,14 +19,14 @@ def color_dist (c1, c2)
(c1[4..5].hex - c2[4..5].hex).abs (c1[4..5].hex - c2[4..5].hex).abs
end end
users.each do |user| #users.each do |user|
tentative_color = rand_color # tentative_color = rand_color
while (colors.detect {|k,v| color_dist(v,tentative_color) < 200}) do # while (colors.detect {|k,v| color_dist(v,tentat#ive_color) < 200}) do
tentative_color = rand_color # tentative_color = rand_color
end # end
#
colors[user] = tentative_color # colors[user] = tentative_color
end #end
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \ plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
fsize '14' rounded dashed fsize '14' rounded dashed
@ -57,7 +60,7 @@ plotstring += %Q[
set title "Screenshot size" set title "Screenshot size"
set output "/home/christoffermadsen/public_html/img/screenshot_size.svg" set output "/home/christoffermadsen/public_html/img/screenshot_size.svg"
set ylabel "Size (MB)" set ylabel "Size (MB)"
set yrange [0:100] set yrange [0:]
set ytics 10 set ytics 10
set mytics 1 set mytics 1