wpf.colorpalette
1.0.0
dotnet add package wpf.colorpalette --version 1.0.0
NuGet\Install-Package wpf.colorpalette -Version 1.0.0
<PackageReference Include="wpf.colorpalette" Version="1.0.0" />
paket add wpf.colorpalette --version 1.0.0
#r "nuget: wpf.colorpalette, 1.0.0"
// Install wpf.colorpalette as a Cake Addin #addin nuget:?package=wpf.colorpalette&version=1.0.0 // Install wpf.colorpalette as a Cake Tool #tool nuget:?package=wpf.colorpalette&version=1.0.0
About The Project
This is a WPF library for generating a color palette from an image ported from Android's Palette API
Installation
The package can be installed by NuGet:
Install-Package Doushi -Version 1.0.0
Or reference it in your project:
<PackageReference Include="Doushi" Version="1.0.0" />
Create a palette
A Palette
object gives you access to the primary colors in an image, as well as the corresponding colors for overlaid text. Use palettes to design your games's style and to dynamically change your games's color scheme based on a given source image.
Generate a Palette instance
Generate a Palette
instance using Palette
's Generate(BitmapSource image)
function
var bm = new BitmapImage(new Uri(@"C:/../...png"));
Palette palette = Palette.Generate(bm);
Based on the standards of material design, the palette library extracts commonly used color profiles from an image. Each profile is defined by a Target, and colors extracted from the texture image are scored against each profile based on saturation, luminance, and population (number of pixels in the texture represented by the color). For each profile, the color with the best score defines that color profile for the given image.
The palette library attempts to extract the following six color profiles:
- Light Vibrant
- Vibrant
- Dark Vibrant
- Light Muted
- Muted
- Dark Muted
Each of Palette
's Get<Profile>Color()
methods returns the color in the palette associated with that particular profile, where <Profile>
is replaced by the name of one of the six color profiles. For example, the method to get the Dark Vibrant color profile is GetDarkVibrantColor()
. Since not all images will contain all color profiles, you can also provide a default color to return.
Color MutedColor = palette.GetMutedColor();
Color VibrantColor = palette.GetVibrantColor();
Color LightMutedColor = palette.GetLightMutedColor();
Color LightVibrantColor = palette.GetLightVibrantColor();
Color DarkMutedColor = palette.GetDarkMutedColor();
Color DarkVibrantColor = palette.GetDarkVibrantColor();
You can aso create more comprehensive color schemes using the GetBodyTextColor()
and GetTitleTextColor()
extension methods the Color
struct. These methods return colors appropriate for use over the swatch’s color.
var muted = palette.GetMutedColor(Colors.White);
mutedBtn.Background = new SolidColorBrush(muted);
mutedBtn.Foreground = new SolidColorBrush(muted.GetTitleTextColor());
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
-
net6.0-windows7.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.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 314 | 4/24/2022 |
First version of the library