Advertisement
Vultraz

Untitled

Nov 30th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. std::vector<color_t> palette(const color_range& cr)
  2. {
  3.     std::vector<color_t> temp, res;
  4.     std::set<color_t> clist;
  5.  
  6.     // Use blue to make master set of possible colors
  7.     for(int i = 255; i != 0; i--) {
  8.         int j = 255 - i;
  9.  
  10.         uint32_t rgb = i;
  11.         temp.push_back(color_t::from_rgba_bytes(rgb));
  12.  
  13.         rgb = (j << 16) + (j << 8) + 255;
  14.         temp.push_back(color_t::from_rgba_bytes(rgb));
  15.     }
  16.  
  17.     // Use recolor function to generate list of possible colors.
  18.     // Could use a special function, would be more efficient, but harder to maintain.
  19.     std::map<color_t, color_t> cmap = recolor_range(cr, temp);
  20.     for(const auto& cm : cmap) {
  21.         clist.insert(cm.second);
  22.     }
  23.  
  24.     res.push_back(cmap[255]);
  25.  
  26.     for(const auto& cs : clist) {
  27.         if(cs != res[0] && cs != 0 && cs != {255, 255, 255}) {
  28.             res.push_back(cs);
  29.         }
  30.     }
  31.  
  32.     return res;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement