ColorHelper.Net 1.0.1

dotnet add package ColorHelper.Net --version 1.0.1                
NuGet\Install-Package ColorHelper.Net -Version 1.0.1                
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="ColorHelper.Net" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ColorHelper.Net --version 1.0.1                
#r "nuget: ColorHelper.Net, 1.0.1"                
#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 ColorHelper.Net as a Cake Addin
#addin nuget:?package=ColorHelper.Net&version=1.0.1

// Install ColorHelper.Net as a Cake Tool
#tool nuget:?package=ColorHelper.Net&version=1.0.1                

ColorHelper.Net

ColorHelper.Net is a library for generating, converting, and mixing colors in C# .Net. It provides a simple and intuitive interface for working with colors in your .Net projects.

Features

  • Generate colors using predefined color names, hex codes or random
  • Convert colors between different color namespaces (eg. system.drawing.common)
  • Mix colors
  • Lighten or darken colors by a specific amount

Installation

To install ColorHelper.Net, you can either clone the repository and build it yourself, or you can use NuGet to install the latest release.

To install using NuGet, run the following command in the Package Manager Console:

Install-Package ColorHelper.Net

Examples

Here is an example of how you might use the ColorConverter class in a C# program:

// Convert a System.Windows.Media.Color to a System.Drawing.Color
System.Windows.Media.Color mediaColor = System.Windows.Media.Colors.Red;
System.Drawing.Color drawingColor = ColorConverter.ConvertColor(mediaColor);

// Convert a hex string to a System.Windows.Media.Color
string hex = "#FF0000"; // red
System.Windows.Media.Color color = ColorConverter.FromHex(hex);

// Convert a System.Drawing.Color to a hue, saturation, and value (HSV)
System.Drawing.Color c = System.Drawing.Color.FromArgb(255, 0, 0); // red
double hue, saturation, value;
ColorConverter.ColorToHSV(c, out hue, out saturation, out value);

// Convert a hue, saturation, and value (HSV) to a System.Drawing.Color
System.Drawing.Color newColor = ColorConverter.ColorFromHSV(hue, saturation, value);

Here is an example of how you might use the ColorMixer class in a C# program:

// Create an array of ColorAmount objects representing different colors and volumes
ColorAmount[] colorDrops = new ColorAmount[3];
colorDrops[0] = new ColorAmount(System.Drawing.Color.FromArgb(255, 255, 0, 0), 50); // red, 50% volume
colorDrops[1] = new ColorAmount(System.Drawing.Color.FromArgb(255, 0, 255, 0), 25); // green, 25% volume
colorDrops[2] = new ColorAmount(System.Drawing.Color.FromArgb(255, 0, 0, 255), 75); // blue, 75% volume

// Mix the colors together
System.Drawing.Color mixedColor = ColorMixer.MixColors(colorDrops);

// Create an array of ShiftColorAmount objects representing different shifted colors and volumes
ShiftColorAmount[] shiftColorDrops = new ShiftColorAmount[3];
shiftColorDrops[0] = new ShiftColorAmount(new ShiftColor(System.Drawing.Color.FromArgb(255, 255, 0, 0), 50, 0, 0), 50); // red, 50% hue shift, 50% volume
shiftColorDrops[1] = new ShiftColorAmount(new ShiftColor(System.Drawing.Color.FromArgb(255, 0, 255, 0), 0, 25, 0), 25); // green, 25% saturation shift, 25% volume
shiftColorDrops[2] = new ShiftColorAmount(new ShiftColor(System.Drawing.Color.FromArgb(255, 0, 0, 255), 0, 0, 75), 75); // blue, 75% value shift, 75% volume

// Mix the shifted colors together
ShiftColor mixedShiftColor = ColorMixer.MixShiftColors(shiftColorDrops);

Here is an example of how you might use the RandomColor class in a C# program:

// Generate a random color with a 20% chance of being one of the primary colors
System.Drawing.Color randomColor = RandomColor.Next(includeAlpha: false, primeColorChance: 0.2);

// Generate a random color with a random hue and saturation based on the base color red, with a saturation of 50% and brightness of 100%
System.Drawing.Color randomHueSaturationColor = RandomColor.Next(RGB_BasicColors.Red, 0.5, 1.0);
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ColorHelper.Net:

Package Downloads
BitmapHelper_Net

fix transparency with image convert

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 409 1/25/2023
1.0.0 322 1/9/2023

target .net 6 & 7