color get_color(func_decl * f) const { if (!f) return CLOSED; color_map::iterator it = m_colors.find_iterator(f); if (it != m_colors.end()) return it->m_value; return OPEN; }
uint CPaletteLinear::Id() { color_map::iterator it, ite; uint val = 0x3456; srand(0x789A); for (it=items.begin(), ite=items.end(); it!=ite; it++) val = HASH(it->first) ^ HASH(it->second.a) ^ HASH(it->second.b) ^ HASH(it->second.c); return val; }
COLORREF CPaletteLinear::Color(_double v) { color_map::iterator it; triplet q; assert(items.size()); // it = (items.size() > 1) ? items.lower_bound(v) : items.begin(); if (it == items.begin()) { q = items.begin()->second; } else if (it == items.end()) { q = it->second; } else { _double v1 = it->first; triplet & more = it->second; it--; _double v0 = it->first; triplet & less = it->second; _double f = (v - v0)/(v1 - v0); q.a = less.a + f * (more.a - less.a); q.b = less.b + f * (more.b - less.b); q.c = less.c + f * (more.c - less.c); } return hsv ? FromHSV(q.a,q.b,q.c) : FromRGB(q.a,q.b,q.c); }
bool operator()(func_decl * new_decl) { // [Leo]: It is not trivial to reuse m_colors between different calls since we are update the graph. // To implement this optimization, we need an incremental topological sort algorithm. // The trick of saving the dependencies will save a lot of time. So, I don't think we really // need a incremental top-sort algo. m_colors.reset(); return main_loop(new_decl); }
void CPaletteLinear::Add(_double v, _double x, _double y, _double z) { triplet q = { x,y,z }; assert( 0.0<=v && v<=1.0 ); assert( 0.0<=x && x<=1.0 ); assert( 0.0<=y && y<=1.0 ); assert( 0.0<=z && z<=1.0 ); items.insert( color_map::value_type(v,q) ); }
void set_color(func_decl * f, color c) { m_colors.insert(f, c); }