#include "iclColor.h" #include #include #include namespace icl{ namespace{ struct ColorMap : public std::map{ ColorMap(){ ColorMap &t = *this; t["black"] = Color(0,0,0); t["white"] = Color(255,255,255); t["red"] = Color(255,0,0); t["green"] = Color(0,255,0); t["blue"] = Color(0,0,255); t["cyan"] = Color(0,255,255); t["magenta"] = Color(255,0,255); t["yellow"] = Color(255,255,0); t["gray200"] = Color(200,200,200); t["gray150"] = Color(150,150,150); t["gray100"] = Color(100,100,100); t["gray50"] = Color(50,50,50); } }; void to_lower2(char &c){ c = tolower(c); } } const Color &iclCreateColor(std::string str){ std::for_each(str.begin(),str.end(),to_lower2); static ColorMap cm; ColorMap::iterator it = cm.find(str); if(it != cm.end()) return it->second; else{ static Color &black = cm["black"]; return black; } } Color translateColor(const std::string &s){ if(s.length() < 2){ return Color(0,0,0); } Color color; std::vector v = icl::parseVecStr(s.substr(1,s.length()-2),","); std::copy(v.begin(),v.begin()+iclMin(3,(int)v.size()),color.data()); return color; } std::string translateColor(const Color &color){ std::ostringstream s; s << '('; for(unsigned int i=0;i