Dynamensions.ColorPalleteGenerator 1.3.0

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

// Install Dynamensions.ColorPalleteGenerator as a Cake Tool
#tool nuget:?package=Dynamensions.ColorPalleteGenerator&version=1.3.0

Dynamensions Color Pallete Generator

A quick and simple color pallet generator. Give it the number of colors needed, and it will produce a pallet. There is also an option to include black or include white in the pallet.

CreateUniqueEvenlyDistrutedColorsUsingRGB

Calulates an even color pallete using circulates from Red to Green to Blue, then repeats with lighter colors. This form of color is commonly used in graphs. IsSorted is available to sort colors by hue, then by RGB values. IsSorted is left to false as this calcuation is common with graphs, and each series of the graph should have contrst to the series before it.

Caution: Colors in this pallet are very limited (maybe 50 or less). Numbers higher than 50 may repeat colors.

CreateUniqueEvenlyDistrutedColorsUsingHSV

Use Hue, Saturation, and Value calulation to evenly distribute colors. The colors are calulated evenly around the hue. This calculation will attempt to divide the hue into evenly distrucited angles. The result is a coor pallet that is evenly distributed across the spectrum. Use this calculation for allowing users to pick from an array of colors, such as themes or Background colors. IsSorted is available to sort colors by hue, then by RGB values. IsSorted is set to true as this calcuation is common with color picking, and moving from one color to the next should be pleasing to the eye.

Note: 100 colors was used for testing with no repteated colors. Although more could be possible, recalcuating with a diffeent saturation and/or value could produce more results. Feel free to experiement!

CreateUniqueSpiraledColorsUsingHSV

Use Hue, Saturation, and Value calulation to evenly distribute colors. The colors are calulated starting with the offset, and use sthe angle to calculate the next hue. Once the calculation reaches back to 0 degrees, the saturatiuon will darken by the step amount. The calculation will continue until the number of colors are met. If the saturation or value reaches 0 or below, it is reset. IsSorted is available to sort colors by hue, then by RGB values. IsSorted is set to true as this calcuation is common with color picking, and moving from one color to the next should be pleasing to the eye.

Note: This was tested using 5000 colors. Though this could crate more, it is not intended to be used to create a full spectrum of colors - like those in photo editing applications. This method is used to applicaitons where a large number of colors are being used.

Example

C#

// Create a list of colors using RGB. Great for charts or presentations that use bright distinct colors.
IEnumerable<string> colors = ColorPalleteGenerator.CreateUniqueEvenlyDistrutedColorsUsingRGB(numerOfColors: 20, includeBlack: true, includeGray: true, includeWhite: true, isSorted: true);

// Create a list of colors using HSV. Great for color pickers.
IEnumerable<string> colors = ColorPalleteGenerator.CreateUniqueEvenlyDistrutedColorsUsingHSV(numerOfColors: 20, includeBlack: true, includeGray: true, includeWhite: true, offset: 0, saturation: 0.99, value: 0.99, isSorted: true);

// Create an enumerable of colors using a spiral algorithm. Used for applications that need a wide variety of colors.
IEnumerable<string> colors = ColorPalleteGenerator.CreateUniqueSpiraledColorsUsingHSV(numerOfColors: 5000, includeBlack: true, includeGray: true, includeWhite: true, offset: 0, angle: 0, saturation: 0.99, value: 0.99, isSorted: true);

VB.NET

' Create a list of colors using RGB. Great for charts or presentations that use bright distinct colors.
Dim colors As IEnumerable(Of String) = ColorPalleteGenerator.CreateUniqueEvenlyDistrutedColorsUsingRGB(numerOfColors:= 20, includeBlack:= true, includeGray:= true, includeWhite:= true, isSorted:= true)

' Create a list of colors using HSV. Great for color pickers.
Dim colors As IEnumerable(Of String) = ColorPalleteGenerator.CreateUniqueEvenlyDistrutedColorsUsingHSV(numerOfColors:= 20, includeBlack:= true, includeGray:= true, includeWhite:= true, offset:= 0, saturation:= 0.99, value:= 0.99, isSorted:= true)

' Create an enumerable of colors using a spiral algorithm. Used for applications that need a wide variety of colors.
Dim colors as IEnumerable(Of String) = ColorPalleteGenerator.CreateUniqueSpiraledColorsUsingHSV(numerOfColors:= 5000, includeBlack:= true, includeGray:= true, includeWhite:= true, offset:= 0, angle:= 0, saturation:= 0.99, value:= 0.99, isSorted:= true);

Notes:

  • All HSV methods start at the hue angle of 0 degrees. You can use the color wheel at Learn how to use hue in CSS colors with HSL as a reference.
  • There are no exception handling so that the error can bubble up. Error handling is left up to the host of this library.
  • Inculing black or white will be included in the number of colors.
  • When using the CreateUniqueSpiraledColorsUsingHSV method, colors are unique to a certian point. The example above is asking for 5000 colors using a hue angle of 1. - This will calculate the next color 1 degree from the last. So, this method can create 5000 unique colors. This hasn't been tested for more than 5000 colors.
  • Sorting colors will sort them by hue then by RGB. This will mimic many color sorting algorithms you see when using a color pallete.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Dynamensions.ColorPalleteGenerator:

Package Downloads
Dynamensions.ColorPicker.Maui

A simple to use color picker for .NET Maui.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 79 5/13/2024
1.2.2.1 62 5/13/2024
1.2.2 64 5/12/2024
1.2.1 59 5/12/2024
1.2.0 71 5/12/2024
1.1.0 70 5/11/2024
1.0.2 69 5/10/2024
1.0.1 73 5/9/2024
1.0.0 77 5/9/2024

- Added IncludeGrey
- Reordered black, grey and white to be after the generated colors.
- Updated readme