Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<color_t> palette(const color_range& cr)
- {
- std::vector<color_t> temp, res;
- std::set<color_t> clist;
- // Use blue to make master set of possible colors
- for(int i = 255; i != 0; i--) {
- int j = 255 - i;
- uint32_t rgb = i;
- temp.push_back(color_t::from_rgba_bytes(rgb));
- rgb = (j << 16) + (j << 8) + 255;
- temp.push_back(color_t::from_rgba_bytes(rgb));
- }
- // Use recolor function to generate list of possible colors.
- // Could use a special function, would be more efficient, but harder to maintain.
- std::map<color_t, color_t> cmap = recolor_range(cr, temp);
- for(const auto& cm : cmap) {
- clist.insert(cm.second);
- }
- res.push_back(cmap[255]);
- for(const auto& cs : clist) {
- if(cs != res[0] && cs != 0 && cs != {255, 255, 255}) {
- res.push_back(cs);
- }
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement