https://github.com/sharpyr/palett
color toolset
https://github.com/sharpyr/palett
ansi ansi-escape-codes c-sharp cli color colorful colorization console dye hsl palett palette rgb
Last synced: 6 days ago
JSON representation
color toolset
- Host: GitHub
- URL: https://github.com/sharpyr/palett
- Owner: sharpyr
- License: mit
- Created: 2021-01-20T11:16:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-29T23:24:29.000Z (about 1 year ago)
- Last Synced: 2026-01-12T12:13:56.755Z (about 1 month ago)
- Topics: ansi, ansi-escape-codes, c-sharp, cli, color, colorful, colorization, console, dye, hsl, palett, palette, rgb
- Language: HTML
- Homepage:
- Size: 569 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

Color space tools
[](https://www.nuget.org/packages/Palett)
[](https://www.nuget.org/packages/Palett)
[](https://libraries.io/nuget/Palett)
[](https://dotnet.microsoft.com/learn/csharp)
[]()
[](https://github.com/sharpyr/Palett/LICENSE)
## Features
- Transform between RGB and HSL color spaces.
- Convert among hex, int, (byte r, byte g, byte b), (float h, float s, float l) and System.Drawing.Color.
- Applicable to styles: Bold, Italic, Underline, and Inverse.
- Render an array or 2d-array of number into colored based on the relative value of each number.
## Content
| Package | Content |
|--------------------|-------------------------------------------------------|
| `Palett` | The core library, including all Palett sub projects |
| `Palett.Cards` | Preset color cards with 14 degrees of color gradients |
| `Palett.Convert` | Convert colors among hex / int / rgb / hsl / Color |
| `Palett.Deco` | Render terminal string color |
| `Palett.Dye` | Colorant (factory) for terminal string |
| `Palett.Fluos` | Colorize array and 2d-array in terminal |
| `Palett.Presets` | Preset color range |
| `Palett.Projector` | Project a number to colored based on a range |
| `Palett.Types` | Base types in Palett series |
| `Palett.Utils` | Base static params of ANSI values |
## Install
Palett targets .NET Standard 2.0, suitable for .NET and .NET Framework.
Install [Palett package](https://www.nuget.org/packages/Palett) and its dependencies.
NuGet Package Manager:
```powershell
Install-Package Palett
```
.NET CLI:
```shell
dotnet add package Palett
```
All versions can be found [on nuget](https://www.nuget.org/packages/Palett#versions-body-tab).
## Usage
### Convert color
```csharp
using Palett.Convert;
// using RGB = System.ValueTuple;
// using HSL = System.ValueTuple;
(byte, byte, byte) rgb = (242, 114, 69);
var hsl = rgb.RgbToHsl();
var hex = hsl.HslToHex();
var rgb2 = Conv.HexToRgb(hex);
var int = rgb2.RgbToInt();
```
### Colorize vector
```csharp
using Palett;
using Palett.Fluos;
var samples = new[] { "foo", "bar", "zen", "16", "24", "32", "64" };
var colored = samples.Fluo(Presets.Planet);
```
# Examples
---------------------
Palett has a test suite in the [test project](https://github.com/sharpyr/Palett/tree/master/Palett.Test/Src).
## Feedback
Palett is licensed under the [MIT](https://github.com/sharpyr/Palett/LICENSE) license.
Bug report and contribution are welcome at [the GitHub repository](https://github.com/sharpyr/Palett).