Ejemplo n.º 1
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.hasMultipleDifferentValues)
        {
            return;
        }
        var C = property.FindPropertyRelative("C");
        var M = property.FindPropertyRelative("M");
        var Y = property.FindPropertyRelative("Y");
        var K = property.FindPropertyRelative("K");

        if (C == null || M == null || Y == null || K == null)
        {
            return;
        }
        var cmyk = new CMYK(C.floatValue, M.floatValue, Y.floatValue, K.floatValue);

        var newColor = EditorGUI.ColorField(position, label, cmyk.ToColor(), false, true, true);

        cmyk = CMYK.from(newColor);

        C.floatValue = cmyk.C;
        M.floatValue = cmyk.M;
        Y.floatValue = cmyk.Y;
        K.floatValue = cmyk.K;
    }
Ejemplo n.º 2
0
        private void PasteColor_Click(object sender, EventArgs e)
        {
            Button b = sender as Button;

            if (b == null)
            {
                return;
            }

            string clipboardText = Clipboard.GetText();

            if (string.IsNullOrEmpty(clipboardText))
            {
                return;
            }

            switch (b.Name)
            {
            case "btn_PasteRGB":

                Color rgb = Color.White;

                if (ColorHelper.ParseRGB(clipboardText, out rgb))
                {
                    cp_ColorPickerMain.SelectedColor = rgb;
                }
                break;

            case "btn_PasteHSB":

                HSB hsb = Color.White;

                if (ColorHelper.ParseHSB(clipboardText, out hsb))
                {
                    cp_ColorPickerMain.SelectedColor = hsb.ToColor();
                }
                break;

            case "btn_PasteHSL":

                HSL hsl = Color.White;

                if (ColorHelper.ParseHSL(clipboardText, out hsl))
                {
                    cp_ColorPickerMain.SelectedColor = hsl.ToColor();
                }
                break;

            case "btn_PasteCMYK":

                CMYK cmyk = Color.White;

                if (ColorHelper.ParseCMYK(clipboardText, out cmyk))
                {
                    cp_ColorPickerMain.SelectedColor = cmyk.ToColor();
                }
                break;
            }
        }
Ejemplo n.º 3
0
        private COLOR GetColor()
        {
            COLOR mycolor = Color.White;

            switch (this.colorFormat)
            {
            case ColorFormat.RGB:
                mycolor = new COLOR((short)values[0], (short)values[1], (short)values[2]);
                break;

            case ColorFormat.ARGB:
                mycolor = new COLOR((short)values[0], (short)values[1], (short)values[2], (short)values[3]);
                break;

            case ColorFormat.CMYK:
                CMYK c = new CMYK(0, 0, 0, 0);
                c.C100 = (float)values[0];
                c.M100 = (float)values[1];
                c.Y100 = (float)values[2];
                c.K100 = (float)values[3];

                mycolor = c.ToColor();
                break;

            case ColorFormat.HSB:
            case ColorFormat.HSV:
                HSB hsb = new HSB(0, 0, 0);

                hsb.Hue360        = (float)values[0];
                hsb.Saturation100 = (float)values[1];
                hsb.Brightness100 = (float)values[2];

                mycolor = hsb.ToColor();
                break;

            case ColorFormat.HSL:
                HSL hsl = new HSL(0, 0, 0);

                hsl.Hue360        = (float)values[0];
                hsl.Saturation100 = (float)values[1];
                hsl.Lightness100  = (float)values[2];

                mycolor = hsl.ToColor();
                break;
            }

            return(mycolor);
        }