Advertisement
timeshifter

color cheer interpolator

Jul 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. //_r, _g, and _b are the current color values
  2. int _max = 100; //cheer amount that will simply change the color to the specified color
  3.                 //anything less will interpolate and shift dynamically
  4.  
  5. //values received from chat message
  6. cheer = 57;
  7. cheer_red = 230;
  8. cheer_green = 110;
  9. cheer_blue = 0;
  10.  
  11. double interp_value = cheer >= _max ? 1.0 : cheer / _max; //calculate interpolation amount
  12.  
  13. _r += ((cheer_red - _r) * interp_value);
  14. _g += ((cheer_green - _g) * interp_value);
  15. _b += ((cheer_blue - _b) * interp_value);
  16. //clamp _r, _g, and _b, and they are now the transformed color
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement