Beispiel #1
0
        internal static void PushColor(LGuiStyleColorIndex Index, LGuiColor Color)
        {
            var Backup = new LGuiStyleColorBackup(Index, GetColor(Index));

            ColorStack.Push(Backup);
            Colors[(int)Index] = Color;
        }
Beispiel #2
0
 internal static void SetColorPickerHsv(string Title, LGuiColor Hsv)
 {
     if (ColorPickerHsv.ContainsKey(Title))
     {
         ColorPickerHsv[Title] = Hsv;
     }
     else
     {
         ColorPickerHsv.Add(Title, Hsv);
     }
 }
Beispiel #3
0
        /// <summary>
        /// h = r
        /// s = g
        /// v = b
        /// </summary>
        /// <returns></returns>
        public static LGuiColor Rgb2Hsv(LGuiColor Rgb)
        {
            var H = 0.0f;
            var S = 0.0f;
            var V = 0.0f;
            var R = Rgb.R;
            var G = Rgb.G;
            var B = Rgb.B;

            var Max = LGuiMisc.Max(LGuiMisc.Max(R, G), B);
            var Min = LGuiMisc.Min(LGuiMisc.Min(R, G), B);

            if (Max == Min)
            {
                H = 0;
            }
            else if (Max == R)
            {
                if (G >= B)
                {
                    H = (G - B) / (Max - Min) * 60.0f;
                }
                else
                {
                    H = (G - B) / (Max - Min) * 60.0f + 360.0f;
                }
            }
            else if (Max == G)
            {
                H = (B - R) / (Max - Min) * 60.0f + 120.0f;
            }
            else if (Max == B)
            {
                H = (R - G) / (Max - Min) * 60.0f + 240.0f;
            }

            if (Max == 0)
            {
                S = 0;
            }
            else
            {
                S = (Max - Min) / Max;
            }

            V = Max;

            return(new LGuiColor(H / 360.0f, S, V, Rgb.A));
        }
Beispiel #4
0
        /// <summary>
        /// h = r
        /// s = g
        /// v = b
        /// </summary>
        /// <returns></returns>
        public static LGuiColor Hsv2Rgb(LGuiColor Hsv)
        {
            var H = Hsv.R * 360.0f;
            var S = Hsv.G;
            var V = Hsv.B;
            var A = Hsv.A;

            if (S == 0)
            {
                return(new LGuiColor(V, V, V, A));
            }

            H /= 60.0f;
            var I = (int)H;
            var F = H - I;
            var P = V * (1 - S);
            var Q = V * (1 - F * S);
            var T = V * (1 - (1 - F) * S);

            switch (I)
            {
            case 0:
                return(new LGuiColor(V, T, P, A));

            case 1:
                return(new LGuiColor(Q, V, P, A));

            case 2:
                return(new LGuiColor(P, V, T, A));

            case 3:
                return(new LGuiColor(P, Q, V, A));

            case 4:
                return(new LGuiColor(T, P, V, A));

            case 5:
                return(new LGuiColor(V, P, Q, A));

            default:
                return(new LGuiColor(V, P, Q, A));
            }
        }
Beispiel #5
0
 internal LGuiStyleColorBackup(LGuiStyleColorIndex Index, LGuiColor Color)
 {
     this.Index = Index;
     this.Color = Color;
 }
Beispiel #6
0
 public static bool ColorPicker(string Title, ref LGuiColor Color)
 {
     return(LGuiColorPicker.OnProcess(Title, new LGuiVec2(250, 300), ref Color));
 }
Beispiel #7
0
 public static void Separator(LGuiColor Color)
 {
     LGuiSeparator.OnProcess(Color);
 }
Beispiel #8
0
 public static bool ColorButton(string Title, LGuiColor Color, LGuiVec2 Size)
 {
     return(LGuiColorButton.OnProcess(Title, Color, Size));
 }
Beispiel #9
0
 public static void Text(LGuiColor Color, string Format, params object[] Args)
 {
     LGuiText.OnProcess(Color, Format, Args);
 }