Esempio n. 1
0
        /// <summary>
        /// Called When slider 0 updates (L or B)
        /// </summary>
        /// <param name="value"></param>
        private void UpdateColorFromSlider2(ChangeEvent <float> value)
        {
            UpdatePrevColor();
            switch (_mode)
            {
            case SliderMode.HSL:
                // calculate color
                _currentColor = ColorUtility.HSL(_prevHue, _prevSat, (int)value.newValue, _currentColor.a);

                // update other sliders
                UpdateSaturationSlider(GetHue(), GetSat(), GetLum());
                break;

            case SliderMode.RGB:
                // calculate color
                _currentColor = ColorUtility.RGB((int)(_currentColor.r * 255), (int)(_currentColor.g * 255), (int)value.newValue, (int)(_currentColor.a * 255));

                // update other sliders
                UpdateRedSlider();
                UpdateGreenSlider();
                break;
            }

            DoCommonUpdateFromSliders();
        }
Esempio n. 2
0
        /// <summary>
        /// Called When slider 0 updates (H or R)
        /// </summary>
        /// <param name="value"></param>
        private void UpdateColorFromSlider0(ChangeEvent <float> value)
        {
            UpdatePrevColor();
            switch (_mode)
            {
            case SliderMode.HSL:
                // calculate color
                _currentColor = ColorUtility.HSL((int)value.newValue, _prevSat, _prevLum, _currentColor.a);

                // update other sliders
                int hue = GetHue();
                int sat = GetSat();
                int lum = GetLum();
                UpdateSaturationSlider(hue, sat, lum);
                UpdateLuminanceSlider(hue, sat, lum);
                break;

            case SliderMode.RGB:
                // calculate color
                _currentColor = ColorUtility.RGB((int)value.newValue, (int)(_currentColor.g * 255), (int)(_currentColor.b * 255), (int)(_currentColor.a * 255));

                // update other sliders
                UpdateGreenSlider();
                UpdateBlueSlider();
                break;
            }

            DoCommonUpdateFromSliders();
        }
Esempio n. 3
0
 private void UpdateLuminanceSlider(int hue, int sat, int lum)
 {
     _colorSliders[2].value = lum;
     _colorSliders[2].SetGradientColors(ColorUtility.HSL(hue, sat, 0), ColorUtility.HSL(hue, sat, 50), ColorUtility.HSL(hue, sat, 100));
 }
Esempio n. 4
0
 private void UpdateSaturationSlider(int hue, int sat, int lum)
 {
     _colorSliders[1].value = sat;
     _colorSliders[1].SetGradientColors(ColorUtility.HSL(hue, 0, lum), ColorUtility.HSL(hue, 100, lum));
 }