rudimentary solution for generating non-similar colors
This commit is contained in:
parent
60907f1076
commit
d27fc0d210
17
plot.rb
17
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' \
|
||||
|
|
Loading…
Reference in New Issue
Block a user