diff --git a/plot.rb b/plot.rb index 33221ea..768154a 100644 --- a/plot.rb +++ b/plot.rb @@ -6,8 +6,23 @@ log_dir = LOG_DIR colors = {} +def rand_color + "%06x" % (rand * 0xffffff) +end + +def color_dist (c1, c2) + (c1[0..1].hex - c2[0..1].hex).abs + + (c1[2..3].hex - c2[2..3].hex).abs + + (c1[4..5].hex - c2[4..5].hex).abs +end + users.each do |user| - colors[user] = "%06x" % (rand * 0xffffff) + tentative_color = rand_color + while (colors.detect {|k,v| color_dist(v,tentative_color) < 200}) do + tentative_color = rand_color + end + + colors[user] = tentative_color end plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \