Monet 0.0.4.1

Suggested Alternatives

MaterialColorUtilities

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

// Install Monet as a Cake Tool
#tool nuget:?package=Monet&version=0.0.4.1                

Monet

.NET library for generating Material Color Palettes from an image or a color

Based on https://material-foundation.github.io/material-theme-builder/app.js

Features

Generate a seed primary color from an image (for example the user's wallpaper):

string imageId = "Monet.Samples.Assets.5_wallpaper.webp";
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageId)!;
SKBitmap bitmap = SKBitmap.Decode(stream).Resize(new SKImageInfo(112,112), SKFilterQuality.Medium);
uint[] pixels = bitmap.Pixels.Select(p => (uint)p).ToArray();

uint seedColor = Utils.SeedFromImage(pixels);

Use that color to create a CorePalette that can be used to create any tone of any key color:

CorePalette corePalette = new(seedColor);
Color color = corePalette.Secondary[55].ToColor();

Map the CorePalette to any Material Design 3 named color using Theme

Theme theme = new(corePalette);
Color primaryContainer = theme.PrimaryContainer;

Set Theme.IsDark to true to get the dark colors:

theme.IsDark = true;
Color darkTertiary = theme.Tertiary;

Theme uses the default Material Design 3 mapping of tokens. This can be changed by making your own theme:

public class MyTheme : Theme
{
    public MyTheme(CorePalette corePalette) : base(corePalette) { }

    protected override uint GetBackgroundLight() => Palette.Primary[98];
    protected override uint GetSurfaceLight() => Palette.Neutral[100];
    protected override uint GetSurfaceDark() => Palette.Neutral[20];
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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.