+
+ float best_score = 0;
+ for(unsigned i=0; (i<100 && best_score<1); ++i)
+ {
+ GL::Color c;
+ c.r = rand()*1.0/RAND_MAX;
+ c.g = rand()*1.0/RAND_MAX;
+ c.b = rand()*1.0/RAND_MAX;
+ float high = max(max(c.r, c.g), c.b);
+ c = c*(1.0/high);
+ if(number<1024)
+ {
+ float low = min(min(c.r, c.g), c.b);
+ c = (c+-low)*(1/(1-low));
+ }
+ else
+ c = c*0.6+0.4;
+
+ float score = 2;
+ const map<unsigned, Port *> &ports = netvis.get_ports();
+ for(map<unsigned, Port *>::const_iterator j=ports.begin(); j!=ports.end(); ++j)
+ {
+ const GL::Color &other = j->second->get_color();
+ float dr = c.r-other.r;
+ float dg = c.g-other.g;
+ float db = c.b-other.b;
+ score = min(score, dr*dr+dg*dg+db*db);
+ }
+ if(score>best_score)
+ {
+ best_score = score;
+ color = c;
+ }
+ }
+ color.a = 0.4f;
+
+ GL::MeshBuilder bld(mesh);
+ bld.begin(GL::QUADS);
+ bld.color(color.r, color.g, color.b, color.a);
+ for(unsigned x=0; x<=4; x+=2)
+ {
+ bld.vertex(x+0, 0);
+ bld.vertex(x+10, 0);
+ bld.vertex(x+10, 10);
+ bld.vertex(x+0, 10);
+ }
+ bld.end();
+}
+
+void Port::render() const
+{
+ GL::PushMatrix push_;
+ mesh.draw();
+ GL::translate(16, 1, 0);
+ GL::scale_uniform(10);
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+ netvis.get_font().draw_string(name, imm);
+ GL::Texture::unbind();