internal static void PushColor(LGuiStyleColorIndex Index, LGuiColor Color) { var Backup = new LGuiStyleColorBackup(Index, GetColor(Index)); ColorStack.Push(Backup); Colors[(int)Index] = Color; }
internal static void SetColorPickerHsv(string Title, LGuiColor Hsv) { if (ColorPickerHsv.ContainsKey(Title)) { ColorPickerHsv[Title] = Hsv; } else { ColorPickerHsv.Add(Title, Hsv); } }
/// <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)); }
/// <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)); } }
internal LGuiStyleColorBackup(LGuiStyleColorIndex Index, LGuiColor Color) { this.Index = Index; this.Color = Color; }
public static bool ColorPicker(string Title, ref LGuiColor Color) { return(LGuiColorPicker.OnProcess(Title, new LGuiVec2(250, 300), ref Color)); }
public static void Separator(LGuiColor Color) { LGuiSeparator.OnProcess(Color); }
public static bool ColorButton(string Title, LGuiColor Color, LGuiVec2 Size) { return(LGuiColorButton.OnProcess(Title, Color, Size)); }
public static void Text(LGuiColor Color, string Format, params object[] Args) { LGuiText.OnProcess(Color, Format, Args); }