Dynamensions.ColorPalleteGenerator
1.3.0
dotnet add package Dynamensions.ColorPalleteGenerator --version 1.3.0
NuGet\Install-Package Dynamensions.ColorPalleteGenerator -Version 1.3.0
<PackageReference Include="Dynamensions.ColorPalleteGenerator" Version="1.3.0" />
paket add Dynamensions.ColorPalleteGenerator --version 1.3.0
#r "nuget: Dynamensions.ColorPalleteGenerator, 1.3.0"
// 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/orvalue
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 for5000
colors using a hue angle of1
. - This will calculate the next color1
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 | Versions 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. |
-
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.
- Added IncludeGrey
- Reordered black, grey and white to be after the generated colors.
- Updated readme