close

def id_to_color(id)
r = id % 255
g = (id >> 8) % 255
b = (id >> 16) % 255
"rgb(#{r}, #{g}, #{b})"
end

Don't ask me what the rationale behind this was...