Пример #1
0
 public void UpdateNewColor(Color color)
 {
     m_newColor     = color;
     m_newColorHSV  = new ColorHSV(m_newColor);
     m_newColorLab  = new ColorLab(m_newColor);
     m_newColorHex  = new ColorHex(m_newColor);
     m_newColorCMYK = new ColorCMYK(m_newColor);
     Refresh();
 }
Пример #2
0
 public void InputChangedLab_b(string str)
 {
     if (str == "" || str == "-" || inputFieldLock)
     {
         return;
     }
     m_newColorLab.b = Mathf.Clamp(int.Parse(str), -128, 127);
     m_newColor      = m_newColorLab.ToColor();
     m_newColorHSV   = new ColorHSV(m_newColor);
     m_newColorHex   = new ColorHex(m_newColor);
     m_newColorCMYK  = new ColorCMYK(m_newColor);
     RefreshInputField();
 }
Пример #3
0
 public void InputChangedHex(string str)
 {
     if (str == m_newColorHex.hex || inputFieldLock)
     {
         return;
     }
     m_newColorHex  = new ColorHex(str);
     m_newColor     = m_newColorHex.ToColor();
     m_newColorHSV  = new ColorHSV(m_newColor);
     m_newColorLab  = new ColorLab(m_newColor);
     m_newColorCMYK = new ColorCMYK(m_newColor);
     RefreshInputField();
     RefreshPicker();
 }
Пример #4
0
 public void InputChangedCMYK_K(string str)
 {
     if (str == "" || str == "-" || inputFieldLock)
     {
         return;
     }
     m_newColorCMYK.k = Mathf.Clamp01(int.Parse(str) / 100.0f);
     m_newColor       = m_newColorCMYK.ToColor();
     m_newColorHSV    = new ColorHSV(m_newColor);
     m_newColorLab    = new ColorLab(m_newColor);
     m_newColorHex    = new ColorHex(m_newColor);
     RefreshInputField();
     RefreshPicker();
 }
Пример #5
0
 public void InputChangedRGB_B(string str)
 {
     if (str == "" || str == "-" || inputFieldLock)
     {
         return;
     }
     m_newColor.b   = Mathf.Clamp01(int.Parse(str) / 255.0f);
     m_newColorHSV  = new ColorHSV(m_newColor);
     m_newColorLab  = new ColorLab(m_newColor);
     m_newColorHex  = new ColorHex(m_newColor);
     m_newColorCMYK = new ColorCMYK(m_newColor);
     RefreshInputField();
     RefreshPicker();
 }
Пример #6
0
 public void InputChangedHSV_H(string str)
 {
     if (str == "" || str == "-" || inputFieldLock)
     {
         return;
     }
     m_newColorHSV.h = Mathf.Clamp(int.Parse(str), 0, 360);
     m_newColor      = m_newColorHSV.ToColor();
     m_newColorLab   = new ColorLab(m_newColor);
     m_newColorHex   = new ColorHex(m_newColor);
     m_newColorCMYK  = new ColorCMYK(m_newColor);
     RefreshInputField();
     RefreshPicker();
 }
Пример #7
0
        public void RefreshColor()
        {
            try
            {
                switch (mode)
                {
                case Mode.HSV_H:
                {
                    float h = pickBar.value * 360.0f;
                    float s = pickArea.value.x;
                    float v = pickArea.value.y;

                    m_newColorHSV = new ColorHSV(h, s, v);
                    m_newColor    = m_newColorHSV.ToColor();
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.HSV_S:
                {
                    float h = pickArea.value.x * 360.0f;
                    float s = pickBar.value;
                    float v = pickArea.value.y;

                    m_newColorHSV = new ColorHSV(h, s, v);
                    m_newColor    = m_newColorHSV.ToColor();
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.HSV_V:
                {
                    float h = pickArea.value.x * 360.0f;
                    float s = pickArea.value.y;
                    float v = pickBar.value;

                    m_newColorHSV = new ColorHSV(h, s, v);
                    m_newColor    = m_newColorHSV.ToColor();
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.RGB_R:
                {
                    float r = pickBar.value;
                    float g = pickArea.value.y;
                    float b = pickArea.value.x;

                    m_newColor    = new Color(r, g, b);
                    m_newColorHSV = new ColorHSV(m_newColor);
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.RGB_G:
                {
                    float r = pickArea.value.y;
                    float g = pickBar.value;
                    float b = pickArea.value.x;

                    m_newColor    = new Color(r, g, b);
                    m_newColorHSV = new ColorHSV(m_newColor);
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.RGB_B:
                {
                    float r = pickArea.value.x;
                    float g = pickArea.value.y;
                    float b = pickBar.value;

                    m_newColor    = new Color(r, g, b);
                    m_newColorHSV = new ColorHSV(m_newColor);
                    m_newColorLab = new ColorLab(m_newColor);
                }
                break;

                case Mode.Lab_L:
                {
                    float L = pickBar.value * 100.0f;
                    float a = pickArea.value.x * 255.0f - 128.0f;
                    float b = pickArea.value.y * 255.0f - 128.0f;

                    m_newColorLab = new ColorLab(L, a, b);
                    m_newColor    = m_newColorLab.ToColor();
                    m_newColorHSV = new ColorHSV(m_newColor);
                }
                break;

                case Mode.Lab_a:
                {
                    float L = pickArea.value.y * 100.0f;
                    float a = pickBar.value * 255.0f - 128.0f;
                    float b = pickArea.value.x * 255.0f - 128.0f;

                    m_newColorLab = new ColorLab(L, a, b);
                    m_newColor    = m_newColorLab.ToColor();
                    m_newColorHSV = new ColorHSV(m_newColor);
                }
                break;

                case Mode.Lab_b:
                {
                    float L = pickArea.value.y * 100.0f;
                    float a = pickArea.value.x * 255.0f - 128.0f;
                    float b = pickBar.value * 255.0f - 128.0f;

                    m_newColorLab = new ColorLab(L, a, b);
                    m_newColor    = m_newColorLab.ToColor();
                    m_newColorHSV = new ColorHSV(m_newColor);
                }
                break;

                default:
                    break;
                }

                m_newColorHex  = new ColorHex(m_newColor);
                m_newColorCMYK = new ColorCMYK(m_newColor);
            } catch
            {
            }
            RefreshInputField();
        }