예제 #1
0
        public static HSBColor Lerp(HSBColor a, HSBColor b, float t)
        {
            float h, s;

            //check special case black (color.b==0): interpolate neither hue nor saturation!
            //check special case grey (color.s==0): don't interpolate hue!
            if (a.brightness == 0)
            {
                h = b.hue;
                s = b.saturation;
            }
            else if (b.brightness == 0)
            {
                h = a.hue;
                s = a.saturation;
            }
            else
            {
                if (a.saturation == 0)
                {
                    h = b.hue;
                }
                else if (b.saturation == 0)
                {
                    h = a.hue;
                }
                else
                {
                    // works around bug with LerpAngle
                    float angle = Mathf.LerpAngle(a.hue * 360f, b.hue * 360f, t);
                    while (angle < 0f)
                    {
                        angle += 360f;
                    }
                    while (angle > 360f)
                    {
                        angle -= 360f;
                    }
                    h = angle / 360f;
                }
                s = Mathf.Lerp(a.saturation, b.saturation, t);
            }
            return(new HSBColor(h, s, Mathf.Lerp(a.brightness, b.brightness, t), Mathf.Lerp(a.alpha, b.alpha, t)));
        }
예제 #2
0
        void Start()
        {
            HSBColor hsbColor = new HSBColor(color);

            if (m_randomHue)
            {
                hsbColor.hue = Random.Range(m_minHue, m_maxHue);
            }
            if (m_randomSaturation)
            {
                hsbColor.saturation = Random.Range(m_minSaturation, m_maxSaturation);
            }
            if (m_randomBrightness)
            {
                hsbColor.brightness = Random.Range(m_minBrightness, m_maxBrightness);
            }
            if (m_randomAlpha)
            {
                hsbColor.alpha = Random.Range(m_minAlpha, m_maxAlpha);
            }
            color = hsbColor.ToColor();
        }
예제 #3
0
        public static void Test()
        {
            HSBColor color;

            color = new HSBColor(Color.red);
            Debug.Log("red: " + color);

            color = new HSBColor(Color.green);
            Debug.Log("green: " + color);

            color = new HSBColor(Color.blue);
            Debug.Log("blue: " + color);

            color = new HSBColor(Color.grey);
            Debug.Log("grey: " + color);

            color = new HSBColor(Color.white);
            Debug.Log("white: " + color);

            color = new HSBColor(new Color(0.4f, 1f, 0.84f, 1f));
            Debug.Log("0.4, 1f, 0.84: " + color);

            Debug.Log("164,82,84   .... 0.643137f, 0.321568f, 0.329411f  :" + ToColor(new HSBColor(new Color(0.643137f, 0.321568f, 0.329411f))));
        }
예제 #4
0
 void Awake()
 {
     color = new HSBColor(GetComponent <ParticleSystem>().main.startColor.color);
 }