見たらなかったので改変、自作しました。140種類の色に対応しています。色名からRGB形式のstring(Ex. (255,255,255))に変換しています。見つからなかったなら白を返します。
// // HTML color names, in both the RGB 888 (24 bit) and RGB 565 (16 bit) spaces. All // values taken from https://en.wikipedia.org/wiki/Web_colors#X11_color_names // // MIT LICENSE // // // Copyright 2020 M Hotchin // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files(the "Software"), to deal in the Software // without restriction, including without limitation the rights to use, copy, modify, // merge, publish, distribute, sublicense, and/or sell copies of the Software, andto // permit persons to whom the Software is furnished to do so, subject to the following // conditions : // // The above copyright notice and this permission notice shall be included in all copies // or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace RGB565 { struct ColorStruct{ char name[25]; int R; int G; int B; }; struct ColorStruct color_table[] = { // Pink colors {"Pink ",0xFF, 0xC0, 0xCB}, {"LightPink ",0xFF, 0xB6, 0xC1}, {"HotPink ",0xFF, 0x69, 0xB4}, {"DeepPink ",0xFF, 0x14, 0x93}, {"PaleVioletRed ",0xDB, 0x70, 0x93}, {"MediumVioletRed ",0xC7, 0x15, 0x85}, // Red colors {"LightSalmon ",0xFF, 0xA0, 0x7A}, {"Salmon ",0xFA, 0x80, 0x72}, {"DarkSalmon ",0xE9, 0x96, 0x7A}, {"LightCoral ",0xF0, 0x80, 0x80}, {"IndianRed ",0xCD, 0x5C, 0x5C}, {"Crimson ",0xDC, 0x14, 0x3C}, {"Firebrick ",0xB2, 0x22, 0x22}, {"DarkRed ",0x8B, 0x00, 0x00}, {"Red ",0xFF, 0x00, 0x00}, // Orange colors {"OrangeRed ",0xFF, 0x45, 0x00}, {"Tomato ",0xFF, 0x63, 0x47}, {"Coral ",0xFF, 0x7F, 0x50}, {"DarkOrange ",0xFF, 0x8C, 0x00}, {"Orange ",0xFF, 0xA5, 0x00}, // Yellow colors {"Yellow ",0xFF, 0xFF, 0x00}, {"LightYellow ",0xFF, 0xFF, 0xE0}, {"LemonChiffon ",0xFF, 0xFA, 0xCD}, {"LightGoldenrodYellow ",0xFA, 0xFA, 0xD2}, {"PapayaWhip ",0xFF, 0xEF, 0xD5}, {"Moccasin ",0xFF, 0xE4, 0xB5}, {"PeachPuff ",0xFF, 0xDA, 0xB9}, {"PaleGoldenrod ",0xEE, 0xE8, 0xAA}, {"Khaki ",0xF0, 0xE6, 0x8C}, {"DarkKhaki ",0xBD, 0xB7, 0x6B}, {"Gold ",0xFF, 0xD7, 0x00}, // Brown colors {"Cornsilk ",0xFF, 0xF8, 0xDC}, {"BlanchedAlmond ",0xFF, 0xEB, 0xCD}, {"Bisque ",0xFF, 0xE4, 0xC4}, {"NavajoWhite ",0xFF, 0xDE, 0xAD}, {"Wheat ",0xF5, 0xDE, 0xB3}, {"Burlywood ",0xDE, 0xB8, 0x87}, {"Tan ",0xD2, 0xB4, 0x8C}, {"RosyBrown ",0xBC, 0x8F, 0x8F}, {"SandyBrown ",0xF4, 0xA4, 0x60}, {"Goldenrod ",0xDA, 0xA5, 0x20}, {"DarkGoldenrod ",0xB8, 0x86, 0x0B}, {"Peru ",0xCD, 0x85, 0x3F}, {"Chocolate ",0xD2, 0x69, 0x1E}, {"SaddleBrown ",0x8B, 0x45, 0x13}, {"Sienna ",0xA0, 0x52, 0x2D}, {"Brown ",0xA5, 0x2A, 0x2A}, {"Maroon ",0x80, 0x00, 0x00}, // Green colors {"DarkOliveGreen ", 0x55, 0x6B, 0x2F}, {"Olive ", 0x80, 0x80, 0x00}, {"OliveDrab ", 0x6B, 0x8E, 0x23}, {"YellowGreen ", 0x9A, 0xCD, 0x32}, {"LimeGreen ", 0x32, 0xCD, 0x32}, {"Lime ", 0x00, 0xFF, 0x00}, {"LawnGreen ", 0x7C, 0xFC, 0x00}, {"Chartreuse ", 0x7F, 0xFF, 0x00}, {"GreenYellow ", 0xAD, 0xFF, 0x2F}, {"SpringGreen ", 0x00, 0xFF, 0x7F}, {"MediumSpringGreen ", 0x00, 0xFA, 0x9A}, {"LightGreen ", 0x90, 0xEE, 0x90}, {"PaleGreen ", 0x98, 0xFB, 0x98}, {"DarkSeaGreen ", 0x8F, 0xBC, 0x8F}, {"MediumAquamarine ", 0x66, 0xCD, 0xAA}, {"MediumSeaGreen ", 0x3C, 0xB3, 0x71}, {"SeaGreen ", 0x2E, 0x8B, 0x57}, {"ForestGreen ", 0x22, 0x8B, 0x22}, {"Green ", 0x00, 0x80, 0x00}, {"DarkGreen ", 0x00, 0x64, 0x00}, // Cyan colors {"Aqua ",0x00, 0xFF, 0xFF}, {"Cyan ",0x00, 0xFF, 0xFF}, {"LightCyan ",0xE0, 0xFF, 0xFF}, {"PaleTurquoise ",0xAF, 0xEE, 0xEE}, {"Aquamarine ",0x7F, 0xFF, 0xD4}, {"Turquoise ",0x40, 0xE0, 0xD0}, {"MediumTurquoise ",0x48, 0xD1, 0xCC}, {"DarkTurquoise ",0x00, 0xCE, 0xD1}, {"LightSeaGreen ",0x20, 0xB2, 0xAA}, {"CadetBlue ",0x5F, 0x9E, 0xA0}, {"DarkCyan ",0x00, 0x8B, 0x8B}, {"Teal ",0x00, 0x80, 0x80}, // Blue colors {"LightSteelBlue ",0xB0, 0xC4, 0xDE}, {"PowderBlue ",0xB0, 0xE0, 0xE6}, {"LightBlue ",0xAD, 0xD8, 0xE6}, {"SkyBlue ",0x87, 0xCE, 0xEB}, {"LightSkyBlue ",0x87, 0xCE, 0xFA}, {"DeepSkyBlue ",0x00, 0xBF, 0xFF}, {"DodgerBlue ",0x1E, 0x90, 0xFF}, {"CornflowerBlue ",0x64, 0x95, 0xED}, {"SteelBlue ",0x46, 0x82, 0xB4}, {"RoyalBlue ",0x41, 0x69, 0xE1}, {"Blue ",0x00, 0x00, 0xFF}, {"MediumBlue ",0x00, 0x00, 0xCD}, {"DarkBlue ",0x00, 0x00, 0x8B}, {"Navy ",0x00, 0x00, 0x80}, {"MidnightBlue ",0x19, 0x19, 0x70}, // Purple, violet, and magenta {"Lavender ",0xE6, 0xE6, 0xFA}, {"Thistle ",0xD8, 0xBF, 0xD8}, {"Plum ",0xDD, 0xA0, 0xDD}, {"Violet ",0xEE, 0x82, 0xEE}, {"Orchid ",0xDA, 0x70, 0xD6}, {"Fuchsia ",0xFF, 0x00, 0xFF}, {"Magenta ",0xFF, 0x00, 0xFF}, {"MediumOrchid ",0xBA, 0x55, 0xD3}, {"MediumPurple ",0x93, 0x70, 0xDB}, {"BlueViolet ",0x8A, 0x2B, 0xE2}, {"DarkViolet ",0x94, 0x00, 0xD3}, {"DarkOrchid ",0x99, 0x32, 0xCC}, {"DarkMagenta ",0x8B, 0x00, 0x8B}, {"Purple ",0x80, 0x00, 0x80}, {"Indigo ",0x4B, 0x00, 0x82}, {"DarkSlateBlue ",0x48, 0x3D, 0x8B}, {"SlateBlue ",0x6A, 0x5A, 0xCD}, {"MediumSlateBlue ",0x7B, 0x68, 0xEE}, // White colors {"White ",0xFF, 0xFF, 0xFF}, {"Snow ",0xFF, 0xFA, 0xFA}, {"Honeydew ",0xF0, 0xFF, 0xF0}, {"MintCream ",0xF5, 0xFF, 0xFA}, {"Azure ",0xF0, 0xFF, 0xFF}, {"AliceBlue ",0xF0, 0xF8, 0xFF}, {"GhostWhite ",0xF8, 0xF8, 0xFF}, {"WhiteSmoke ",0xF5, 0xF5, 0xF5}, {"Seashell ",0xFF, 0xF5, 0xEE}, {"Beige ",0xF5, 0xF5, 0xDC}, {"OldLace ",0xFD, 0xF5, 0xE6}, {"FloralWhite ",0xFF, 0xFA, 0xF0}, {"Ivory ",0xFF, 0xFF, 0xF0}, {"AntiqueWhite ",0xFA, 0xEB, 0xD7}, {"Linen ",0xFA, 0xF0, 0xE6}, {"LavenderBlush ",0xFF, 0xF0, 0xF5}, {"MistyRose ",0xFF, 0xE4, 0xE1}, // Gray and black colors {"Gainsboro ",0xDC, 0xDC, 0xDC}, {"LightGray ",0xD3, 0xD3, 0xD3}, {"Silver ",0xC0, 0xC0, 0xC0}, {"DarkGray ",0xA9, 0xA9, 0xA9}, {"Gray ",0x80, 0x80, 0x80}, {"DimGray ",0x69, 0x69, 0x69}, {"LightSlateGray",0x77, 0x88, 0x99}, {"SlateGray ",0x70, 0x80, 0x90}, {"DarkSlateGray ",0x2F, 0x4F, 0x4F}, {"Black ",0x00, 0x00, 0x00} }; } string constraints::convert_color_name_to_rgb(string color_name) { auto iter = color_name.find(","); if (iter != string::npos) { return color_name; } for (auto j = 0; j < sizeof(RGB565::color_table) / sizeof(RGB565::ColorStruct); j++) { string dest_name = RGB565::color_table[j].name; bool fail = false; for (auto m = 0; m < color_name.size(); m++) { if (tolower(color_name[m]) != tolower(dest_name[m])) { fail=true; break; } } if (!fail) { string s = std::to_string(RGB565::color_table[j].R) + ","; s += std::to_string(RGB565::color_table[j].G) + ","; s += std::to_string(RGB565::color_table[j].B) ; return s; } } return "255,255,255"; }
これを、通すと、色名は、全て、RGB形式stringとなります
#shiftdef shiftdef={'公休':('休み',公休),'希望休':('休',希望休),'有給':('有',有給),'業務':('業務',業務),'業務なし日勤':('・',業務なし日勤),'産休':('産',産休)} shift_label_color_map={'公休':[('休み','245,245,245'),('','128,128,128'),('','128,128,128')],'希望休':[('休','173,255,47'),('','128,128,128'),('','128,128,128')],'有給':[('有','128,128,128'),('','128,128,128'),('','128,128,128')],'業務':[('業務','255,224,192'),('業務AM','255,192,128'),('業務PM','255,128,0')],'業務なし日勤':[('・','211,211,211'),('','128,128,128'),('','128,128,128')],'産休':[('産','128,128,128'),('出張','128,128,128'),('','128,128,128')]} #taskdef taskdef={'日直':日直,'振替休日':振替休日,'当直':当直,'セカンド':セカンド,'遅':遅,'Dummy':Dummy,'DummyDay':DummyDay,'臨出':臨出} task_label_color_map={'日直':[('日','255,192,192'),('','128,128,128')],'振替休日':[('振休','238,130,238'),('','128,128,128')],'当直':[('当','192,192,0'),('','128,128,128')],'セカンド':[('セ','192,255,255'),('','128,128,128')],'遅':[('遅','128,255,128'),('','128,128,128')],'Dummy':[('.','224,224,224'),('夜勤禁','128,128,255')],'DummyDay':[('.','255,255,255'),('','128,128,255')],'臨出':[('臨','255,128,0'),('','128,128,128')]}
0 件のコメント:
コメントを投稿