79 lines
2.6 KiB
Markdown
79 lines
2.6 KiB
Markdown
# mcolor - Maxine's Mean Color Library
|
|
|
|
mcolor is a C++20 library designed to provide an efficient suite for color management. Ideal for use in games, console applications, UI, and so forth.
|
|
|
|
## Color as a Class
|
|
|
|
At its heart, mcolor defines fundamental color structures for clear and concise representation:
|
|
|
|
- `Color3`: Represents an RGB color with 8-bit unsigned integer components (uint8_t r, g, b).
|
|
- `Color4`: Extends Color3 to include an alpha channel (uint8_t r, g, b, a).
|
|
|
|
These core types are complemented by a full range of conversion structs, enabling seamless transitions between various color models:
|
|
|
|
- `HSV`, `HSVA`: Hue, Saturation, Value (with Alpha)
|
|
- `RGB`, `RGBA`: Red, Green, Blue (with Alpha) using u8 components.
|
|
- `RGBf`, `RGBAf`: Red, Green, Blue (with Alpha) using float components.
|
|
- `LCH`, `LCHA`: Lightness, Chroma, Hue (with Alpha)
|
|
- `CMYK`: Cyan, Magenta, Yellow, Key (Black)
|
|
|
|
The library also includes organized Color Palettes within dedicated namespaces:
|
|
- `Colors::Primary`, or just `Colors`,
|
|
- <span style='color: red;'>Colors::Reds</span>
|
|
- <span style='color: orange;'>Colors::Oranges</span>
|
|
- <span style='color: yellow;'>Colors::Yellows</span>
|
|
- <span style='color: green;'>Colors::Greens</span>
|
|
- <span style='color: cyan;'>Colors::Cyans</span>
|
|
- <span style='color: blue;'>Colors::Blues</span>
|
|
- <span style='color: purple;'>Colors::Purples</span>
|
|
- <span style='color: pink;'>Colors::Pinks</span>
|
|
- <span style='color: white;'>Colors::Whites</span>
|
|
- <span style='color: gray;'>Colors::Grays</span>
|
|
- <span style='color: brown;'>Colors::Browns</span>
|
|
|
|
offering a rich set of predefined swatches for immediate use.
|
|
|
|
Additionally, we have worked to implement Ansi Escape Codes, console-output utilities, and cross-platform abstraction so that it works the same on Windows and Linux.
|
|
|
|
## Usage
|
|
|
|
Integrating mcolor into your project is straightforward. Here's a quick sample:
|
|
|
|
```cpp
|
|
int main() {
|
|
#ifdef WIN32
|
|
mcolor::windowsSaneify();
|
|
#endif
|
|
|
|
mcolor::printBuiltinColorList();
|
|
mcolor::printAnsiColorTable();
|
|
mcolor::printRGBConsoleTest();
|
|
|
|
|
|
for (float i = 0; i < 360; i+=10.f)
|
|
{
|
|
HSVA hsva {i, 1.f, 1.f};
|
|
|
|
Color4 c = Color4(hsva);
|
|
|
|
std::cout << std::format("{}hue:{} rgb: {},{},{} hex: {}", c.ToEscapeCode(), i, c.r, c.g, c.b, c.ToHex()) << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
```
|
|
|
|
## Acknowledgements
|
|
|
|
This library was created by `maxine`, and is currently maintained by Josh O'Leary.
|
|
|
|
## Contributing
|
|
|
|
Pull requests and issues are always welcome! You know what to do!
|
|
|
|
## License
|
|
|
|
This work is expressly dedicated to the Public Domain under the Unlicense.
|
|
|
|
|