Пример #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 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();
 }
Пример #3
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();
 }
Пример #4
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();
 }
Пример #5
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();
 }
Пример #6
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();
        }
Пример #7
0
        public void Refresh()
        {
            switch (colorPicker.mode)
            {
            case ColorPicker.Mode.HSV_H:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = (float)y / texture.height * 360.0f;
                        color.s     = 1.0f;
                        color.v     = 1.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.HSV_S:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = colorPicker.pickArea.value.x * 360.0f;
                        color.s     = (float)y / texture.height;
                        color.v     = colorPicker.pickArea.value.y;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.HSV_V:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = colorPicker.pickArea.value.x * 360.0f;
                        color.s     = colorPicker.pickArea.value.y;
                        color.v     = (float)y / texture.height;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_R:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = (float)y / texture.height;
                        color.g = colorPicker.pickArea.value.y;
                        color.b = colorPicker.pickArea.value.x;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_G:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = colorPicker.pickArea.value.y;
                        color.g = (float)y / texture.height;
                        color.b = colorPicker.pickArea.value.x;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_B:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = colorPicker.pickArea.value.x;
                        color.g = colorPicker.pickArea.value.y;
                        color.b = (float)y / texture.height;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_L:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = (float)y / texture.height * 100.0f;
                        color.a     = colorPicker.pickArea.value.x * 255.0f - 128.0f;
                        color.b     = colorPicker.pickArea.value.y * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_a:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = colorPicker.pickArea.value.y * 100.0f;
                        color.a     = (float)y / texture.height * 255.0f - 128.0f;
                        color.b     = colorPicker.pickArea.value.x * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_b:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = colorPicker.pickArea.value.y * 100.0f;
                        color.a     = colorPicker.pickArea.value.x * 255.0f - 128.0f;
                        color.b     = (float)y / texture.height * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            default:
                break;
            }
            texture.Apply();
        }
Пример #8
0
        public void Refresh()
        {
            switch (colorPicker.mode)
            {
            case ColorPicker.Mode.HSV_H:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = colorPicker.pickBar.value * 360.0f;
                        color.s     = (float)x / texture.width;
                        color.v     = (float)y / texture.height;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.HSV_S:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = (float)x / texture.width * 360.0f;
                        color.s     = colorPicker.pickBar.value;
                        color.v     = (float)y / texture.height;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.HSV_V:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorHSV color = new ColorHSV();
                        color.h     = (float)x / texture.width * 360.0f;
                        color.s     = (float)y / texture.height;
                        color.v     = colorPicker.pickBar.value;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_R:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = colorPicker.pickBar.value;
                        color.g = (float)y / texture.height;
                        color.b = (float)x / texture.width;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_G:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = (float)y / texture.height;
                        color.g = colorPicker.pickBar.value;
                        color.b = (float)x / texture.width;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.RGB_B:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        Color color = new Color();
                        color.r = (float)x / texture.width;
                        color.g = (float)y / texture.height;
                        color.b = colorPicker.pickBar.value;
                        color.a = 1.0f;
                        texture.SetPixel(x, y, color);
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_L:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = colorPicker.pickBar.value * 100.0f;
                        color.a     = (float)x / texture.width * 255.0f - 128.0f;
                        color.b     = (float)y / texture.height * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_a:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = (float)y / texture.height * 100.0f;
                        color.a     = colorPicker.pickBar.value * 255.0f - 128.0f;
                        color.b     = (float)x / texture.width * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            case ColorPicker.Mode.Lab_b:
            {
                for (int y = 0; y < texture.height; ++y)
                {
                    for (int x = 0; x < texture.width; ++x)
                    {
                        ColorLab color = new ColorLab();
                        color.L     = (float)y / texture.height * 100.0f;
                        color.a     = (float)x / texture.width * 255.0f - 128.0f;
                        color.b     = colorPicker.pickBar.value * 255.0f - 128.0f;
                        color.alpha = 1.0f;
                        texture.SetPixel(x, y, color.ToColor());
                    }
                }
            }
            break;

            default:
                break;
            }
            texture.Apply();
            if (colorPicker.newColorLab != null)
            {
                if (colorPicker.newColorLab.L > 62.0f)
                {
                    indicatorImage.color = Color.black;
                }
                else
                {
                    indicatorImage.color = Color.white;
                }
            }
        }