@palett/fluo-matrix

A colorant to string


Keywords
chalk, color, ansi, ansi-escape-codes, c-sharp, cli, colorful, colorization, console, dye, hsl, palett, palette, rgb
License
MIT
Install
npm install @palett/fluo-matrix@0.9.13

Documentation

Banner

Color space tools

Version Downloads Dependent Libraries Language Compatibility 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 and its dependencies.

NuGet Package Manager:

Install-Package Palett

.NET CLI:

dotnet add package Palett

All versions can be found on nuget.

Usage

Convert color

using Palett.Convert;
// using RGB = System.ValueTuple<byte, byte, byte>;
// using HSL = System.ValueTuple<float, float, float>;

(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

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.

Feedback

Palett is licensed under the MIT license.

Bug report and contribution are welcome at the GitHub repository.