⛱️Color Internals
All of the colors!
Nitrocid KS uses Terminaux to manipulate with the colors and configure them for the kernel to use. The kernel employs several of the color types for the kernel components, your addons, or your mods to use when writing text using the Nitrocid's console writer.
The ConsoleBase
namespace contains a namespace dedicated to color management called Colors that contains a plenty of useful tools for color manipulation. Currently, it contains the following classes:
ColorSelector
KernelColorConversionTools
KernelColorTools
It also contains the following enumerations for different tools:
KernelColorSetErrorReasons
KernelColorType
Scroll down in this page to get started with the list of amazing color tools.
Color types
Nitrocid KS provides you with the following color types to help you make an inspiring theme with nice colors for each type:
Type | Description |
---|---|
| Input text |
| License color |
| Continuable kernel panic text (usually sync'd with Warning) |
| Uncontinuable kernel panic text (usually sync'd with Error) |
| Host name color |
| User name color |
| Background color |
| Neutral text (for general purposes) |
| List entry text |
| List value text |
| Stage text |
| Error text |
| Warning text |
| Option text |
| Banner text |
| Notification title text |
| Notification description text |
| Notification progress text |
| Notification failure text |
| Question text |
| Success text |
| User dollar sign on shell text |
| Tip text |
| Separator text |
| Separator color |
| List title text |
| Development warning text |
| Stage time text |
| General progress text |
| Back option text |
| Low priority notification border color |
| Medium priority notification border color |
| High priority notification border color |
| Table separator |
| Table header |
| Table value |
| Selected option |
| Alternative option |
| Weekend day |
| Event day |
| Table title |
| Today |
| Interactive TUI background color |
| Interactive TUI foreground color |
| Interactive TUI pane background color |
| Interactive TUI pane separator color |
| Interactive TUI pane selected separator color |
| Interactive TUI pane selected item color (foreground) |
| Interactive TUI pane selected item color (background) |
| Interactive TUI pane item color (foreground) |
| Interactive TUI pane item color (background) |
| Interactive TUI option background color |
| Interactive TUI key binding in option color |
| Interactive TUI option foreground color |
| Interactive TUI box background color |
| Interactive TUI box foreground color |
Color selector
The color selector is an interactive TUI that allows you to seamlessly select your favorite color, while getting information about it in the main screen, such as the converted color models, the color levels, and more.
To get information about how to use it, you can find it in the Terminaux manual page:
Color conversion
Your theme files can also support any specifier, as long as the specifier is supported by Terminaux. For a quick reminder, Terminaux supports the three true-color specifiers, alongside the color name or the color number, if you intend to use another color model to select colors:
RGB: Red, Green, and Blue.
<RRR>;<GGG>;<BBB>
where the three variables can be from 0 to 255.
RYB: Red, Yellow, and Blue.
ryb:<RRR>;<YYY>;<BBB>
where the three variables can be from 0 to 255.
CMYK: Cyan, Magenta, and Yellow with the Black Key.
cmyk:<CCC>;<MMM>;<YYY>;<KKK>
where these variables can be from 0 to 100.
CMY: Cyan, Magenta, and Yellow.
cmy:<CCC>;<MMM>;<YYY>
where these variables can be from 0 to 100.
HSL: Hue, Saturation, and Luminance (or Lightness).
hsl:<HHH>;<SSS>;<LLL>
where the Hue can be from 0 to 360 degrees and not radians.
where the Saturation and the Luminance can be from 0 to 100.
HSV: Hue, Saturation, and Value.
hsv:<HHH>;<SSS>;<VVV>
where the Hue can be from 0 to 360 degrees and not radians.
where the Saturation and the Luminance can be from 0 to 100.
The commands provided by the color conversion Extras addon help you convert from a color model, such as RGB, to another color model, such as CMYK.
KernelColorConversionTools
provides you all possible conversion methods to convert a color model to another color model to generate appropriate color specifiers converted to the target unit to create new Color
instances for your mod's appearance.
For example, if you have Cyan, Magenta, and Yellow values and you want a hex code of it, you can use one of the following function overloads of ConvertFromCmykToHex()
:
ConvertFromCmykToHex(int C, int M, int Y, int K)
ConvertFromCmykToHex(string CMYKSequence)
Color tools
Nitrocid KS provides you a built-in color tools class that allows you to manipulate with the colors in various ways. The following types of manipulation are available:
Populating a list of colors
You can get a list of colors with all the kernel color types by using one of the three functions, depending on the type of the population:
Here's an overview of each function:
The first function,
PopulateColorsEmpty()
, populates all the colors for all the kernel color types with the black color for all foreground colors and white for background colors.The second function,
PopulateColorsDefault()
, populates all the colors for all the kernel color types with the default kernel colors for all the colors, regardless of the kernel configuration.The second function,
PopulateColorsCurrent()
, populates all the colors for all the kernel color types with the current kernel colors according to the kernel configuration.
Getting and Setting colors
In addition to the above function, you can also get a color instance from a single color type and set a color for a specified type to your own selected color. These two functions help you do these two tasks simply:
Any changes made to a kernel color type will be saved to the kernel settings upon shutting the kernel down or rebooting it.
Loading a background color
You can clear the console screen with a specified background color by calling this below function, provided that it contains several versions of the function:
There are two versions of this function:
The first parameterless function allows you to clear the console screen with the current kernel background color.
The second function with the color parameter allows you to clear the console screen with the selected background color.
Getting a gray color
You can get a gray foreground color that adapts to the lightness of the background color using a single function, GetGray()
.
This will return either a gray color on dark backgrounds or a neutral text color on bright backgrounds.
Setting a console color
The color tools allows you to set a console color either using the kernel color type, such as a neutral text color, or using a Color
instance to select a custom color. The following functions are available:
In addition to setting the foreground color, you can also make it set the background color by passing true
to background
argument in all the supported console color setting functions above.
Parsing colors
This allows you to easily parse either the color specifier string, the color number from 0 to 255, or the RGB color level values from 0 to 255. The following functions are available:
The following functions are listed:
The first function takes a color specifier and parses it.
The second function takes a color number and parses it.
The third function takes RGB color values and parses them.
Getting a random color
You can get a random color of any type using any of the three functions:
Here's an explanation of what each version does:
The first version only allows you to choose whether you need to select the black color or not. It returns a random color in its true color form.
The second version allows you to choose a color type, along with the above black color selection. It returns a random color in the color type that you select.
The third version allows you to choose a color type and several of the color ranges.
minColor
tomaxColor
: Value can be from 0 to 16 if the type is 16 colors, or from 0 to 255 if the type is 256 colors. Ignored for true color randomization.minColorR
tomaxColorR
: Red level of the color range. Only applies to true color randomization.minColorG
tomaxColorG
: Green level of the color range. Only applies to true color randomization.minColorB
tomaxColorB
: Blue level of the color range. Only applies to true color randomization.
When you turn off black color selection, the function skips the color under the following conditions:
If the color type is true color, it ignores any color that has all the RGB levels of below 30, such as
29;29;29
.If the color type is not true color, it ignores the following colors:
ConsoleColors.Black
ConsoleColors.Grey0
ConsoleColors.Grey3
ConsoleColors.Grey7
Last updated