Advertisement
Vultraz

Untitled

Nov 24th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1.     uint32_t red_to_green(int val, bool for_text){
  2.         const std::vector<uint32_t>& color_scale = for_text ? red_green_scale_text : red_green_scale;
  3.  
  4.         SDL_Color a = int_to_color(*color_scale.begin());
  5.         SDL_Color b = int_to_color(*color_scale.end() - 1);
  6.  
  7.         val = std::max<int>(0, std::min<int>(val, 100));
  8.  
  9.         return
  10.             (((a.r * val + b.r * (1 - val)) ) ) +
  11.             (((a.g * val + b.g * (1 - val)) ) ) +
  12.             (((a.b * val + b.b * (1 - val)) ) ) +
  13.             SDL_ALPHA_OPAQUE;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement