PastelEx 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package PastelEx --version 1.0.2                
NuGet\Install-Package PastelEx -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PastelEx" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PastelEx --version 1.0.2                
#r "nuget: PastelEx, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PastelEx as a Cake Addin
#addin nuget:?package=PastelEx&version=1.0.2

// Install PastelEx as a Cake Tool
#tool nuget:?package=PastelEx&version=1.0.2                

Logo

⚠️ API has changed a bit in this version (1.0.2)! One of changes are methods Pastel(), PastelBg() and PastelDeco(), they are now just Fg, Bg and Deco. Old methods will be removed in future, please switch to the new methods!

PastelEx πŸ’₯

Elevate Your Console Output with Colors and Styles

Inspired by the syntax of Pastel and Crayon. PastelEx wouldn't exist without these incredible libraries.

Tested and Compatible with Windows and Linux terminals.

🎨 Inspiration

Adding ANSI color codes can be a confusing and challenging task to do manually. PastelEx simplifies the process of coloring and styling console output.

βš™οΈ How It Works

Using a simple syntax, like "Hello, World!".Fg(Color.White), wraps your string in a special Unicode character sequence that instructs the terminal to apply color. This library offers benefits such as ease of use and automatic checks for terminal ANSI color support.

πŸ”₯ Example:

using PastelExtended;
using System.Drawing;

Console.WriteLine($"Look, this text is {"colored".Fg("#ffff00")}!".Fg(Color.White));
Console.WriteLine(PastelEx.Gradient("And this one is gradient!", new[] { Color.Magenta, Color.Aqua }));

⚑ Performance Benefits

PastelEx efficiently enhances console output without excessive memory allocation. The library performs exceptionally well in comparison to alternatives.

Benchmark (lower values are better):

|   Method  |      Mean   |   Gen 0   | Allocated |
|-----------|------------:|----------:|----------:|
|   Pastel  | 2,551.55 ns |  1.2665   |   2656 B  |
| PastelEx  |    25.78 ns |  0.0382   |     80 B  |
|   Crayon  |   453.23 ns |  0.6266   |   1312 B  |

πŸ§ͺ Tested and Verified

PastelEx is rigorously tested to ensure accurate and intended color and style rendering. It dynamically checks and adapts to your terminal's ANSI color support, providing a seamless experience.

Note: Avoid explicit calls to PastelEx.Enable(). PastelEx handles ANSI color code display automatically.

🚫 NO_COLOR Compatibility

PastelEx respects the NO_COLOR environment variable. If set, it disables color output to accommodate user preferences.

🚧 What PastelEx Doesn't Offer

While PastelEx empowers your console output, it doesn't provide tools for creating complex Console UI, panels, or tables.

Example Image

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

New methods and properties (and simplified method names)!
NOTE: Old methods are marked as obsolete now.