Answers for "c# color from rgb"

C#
2

c# color hex

this.control.BackColor = System.Drawing.ColorTranslator.FromHtml("#626262");
Posted by: Guest on May-13-2021
0

assign color to value in c#

Color redColor = Color.FromArgb(255, 0, 0);
Posted by: Guest on December-24-2020
0

c# color hex

control.BackColor =  ColorTranslator.FromHtml("#626262");
Posted by: Guest on May-13-2021
0

c# rgb to consolecolor

// Console.ForegroundColor = RGBToConsoleColor(c);
public ConsoleColor RGBToConsoleColor (Color color) {
        if (color.GetSaturation () < 0.5)
            switch ((int) (color.GetBrightness () * 3.5)) {
                case 0:
                    return ConsoleColor.Black;
                case 1:
                    return ConsoleColor.DarkGray;
                case 2:
                    return ConsoleColor.Gray;
                default:
                    return ConsoleColor.White;
            }
        var hue = (int) Math.Round (color.GetHue () / 60, MidpointRounding.AwayFromZero);
        if (color.GetBrightness () < 0.4)
            switch (hue) {
                case 1:
                    return ConsoleColor.DarkYellow;
                case 2:
                    return ConsoleColor.DarkGreen;
                case 3:
                    return ConsoleColor.DarkCyan;
                case 4:
                    return ConsoleColor.DarkBlue;
                case 5:
                    return ConsoleColor.DarkMagenta;
                default:
                    return ConsoleColor.DarkRed;
            }
        switch (hue) {
            case 1:
                return ConsoleColor.Yellow;
            case 2:
                return ConsoleColor.Green;
            case 3:
                return ConsoleColor.Cyan;
            case 4:
                return ConsoleColor.Blue;
            case 5:
                return ConsoleColor.Magenta;
            default:
                return ConsoleColor.Red;
        }
    }
Posted by: Guest on October-13-2020

C# Answers by Framework

Browse Popular Code Answers by Language