Search Unity

Mathf.CorrelatedColorTemperatureToRGB how to reverse the action ?

Discussion in 'Scripting' started by michaljabrzyk, Mar 10, 2018.

  1. michaljabrzyk

    michaljabrzyk

    Joined:
    Apr 15, 2013
    Posts:
    57
    Do some one got any idea how to reverse
    Mathf.CorrelatedColorTemperatureToRGB

    Color ==> color temperature.

    In other words. How to reverse action.

    For now test this metod and it works good.


    [ExecuteInEditMode]
    public class TestClass : MonoBehaviour {
    public float kelvin;
    public float red;
    public float green;
    public float blue;
    public Color color;
    // Use this for initialization
    void Start ()
    {
    kelvin = 1000;
    }
    // Update is called once per frame
    void Update ()
    {
    ColorTemperatureToRGB();
    red = color.r;
    green = color.g;
    blue = color.b;
    }
    public void ColorTemperatureToRGB()
    {
    var red = 0;
    var green = 0;
    var blue = 0;
    color = new Color(red, green, blue);
    if (kelvin >= 1000)
    {
    color = Mathf.CorrelatedColorTemperatureToRGB(kelvin);
    // Debug.Log("Kelvin >= 1000");
    }
    // Debug.Log(color.r);
    // Debug.Log(color.g);
    // Debug.Log(color.b);
    }
    public void RGBToColorTemperature()
    {
    // :-/
    }
    }


    RGDS :)
     
    Last edited: Mar 10, 2018
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,744