Advertisement
pushrbx

Convert Kelvin to grayscale color

Jun 16th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. // kelvin values are around 270-290 normally for room temperature
  2. // we have to scale up those, so we multiply by 10
  3. public Color KelvinToGrayscaleColor(int kelvin)
  4. {
  5.     kelvin *= 10;
  6.     var min = 2200;
  7.         var max = 3800;
  8.     var highestBit = 255;
  9.  
  10.     var result = 0.0;
  11.     if (item <= max && item >= min)
  12.     {
  13.         result = ((double)(highestBit) / ((double)(max - min))) * ((double)(item - min));
  14.     }
  15.  
  16.     return new Color(result, result, result)
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement