PastelEx 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package PastelEx --version 1.0.3
NuGet\Install-Package PastelEx -Version 1.0.3
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.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PastelEx --version 1.0.3
#r "nuget: PastelEx, 1.0.3"
#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.3

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

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 (1)

Showing the top 1 NuGet packages that depend on PastelEx:

Package Downloads
Sygenic.SharedKernel

Common code for Sygenic software

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 514 8/31/2023
1.0.3 144 8/30/2023
1.0.2 180 8/12/2023
1.0.1 166 8/9/2023
1.0.0 173 8/8/2023

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