Изменение цвета в консоли - C#
Формулировка задачи:
И снова здравствуйте.
Встала задача изменить цвет текста при выводе на консоль. Реализовать это необходимо через задание параметров RGB. (про Console.ForegroundColor я знаю, но требуется именно в rgb)
Может кто нибудь знает?
Решение задачи: «Изменение цвета в консоли»
textual
Листинг программы
Private Function ColourLongToWords(ByVal lColour As Long) As String 'Converts an RGB colour number to a string equivalent 'By Si_the_geek, VBForums 'ensure value is within range for colours lColour = lColour And &HFFFFFF 'convert to separate RGB values Dim iRed As Integer, iGreen As Integer, iBlue As Integer iRed = lColour And &HFF iGreen = (lColour \ &H100) And &HFF iBlue = lColour \ &H10000 '"guess" the colour based on these values Dim sColourName As String Select Case iRed Case Is > 170 'lots of red Select Case iGreen Case Is > 170 'lots of green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "White" Case Is > 85: sColourName = "Bright Yellow" Case Else: sColourName = "Yellow" End Select Case Is > 85 'medium green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Pink" Case Is > 85: sColourName = "Magenta" Case Else: sColourName = "Orange" End Select Case Else 'little green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Purple" Case Is > 85: sColourName = "Dark Pink" Case Else: sColourName = "Red" End Select End Select Case Is > 85 'medium red Select Case iGreen Case Is > 170 'lots of green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Cyan" Case Is > 85: sColourName = "Green" Case Else: sColourName = "Bright Green" End Select Case Is > 85 'medium green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Dark Blue" Case Is > 85: sColourName = "Dark Grey" Case Else: sColourName = "Dark Green" End Select Case Else 'little green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Dark Blue" Case Is > 85: sColourName = "Purple" Case Else: sColourName = "Dark Red" End Select End Select Case Else 'little red Select Case iGreen Case Is > 170 'lots of green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Cyan" Case Is > 85: sColourName = "Green" Case Else: sColourName = "Bright Green" End Select Case Is > 85 'medium green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Blue" Case Is > 85: sColourName = "Dark Cyan" Case Else: sColourName = "Dark Green" End Select Case Else 'little green Select Case iBlue 'blue: lots/medium/little Case Is > 170: sColourName = "Bright Blue" Case Is > 85: sColourName = "Dark Blue" Case Else: sColourName = "Black" End Select End Select End Select ColourLongToWords = sColourName End Function
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д