MaterialColorUtilities 0.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package MaterialColorUtilities --version 0.0.6                
NuGet\Install-Package MaterialColorUtilities -Version 0.0.6                
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="MaterialColorUtilities" Version="0.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MaterialColorUtilities --version 0.0.6                
#r "nuget: MaterialColorUtilities, 0.0.6"                
#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 MaterialColorUtilities as a Cake Addin
#addin nuget:?package=MaterialColorUtilities&version=0.0.6

// Install MaterialColorUtilities as a Cake Tool
#tool nuget:?package=MaterialColorUtilities&version=0.0.6                

Material Color Utilities for .NET

This is a C# implementation of Google's Material Color Utilities, that can be used to extract a color from an image and then generate a Material Design 3 color scheme.

Install

Get the package from Nuget: NuGet

Quickstart

Generate a seed color from an image (e.g. the user's wallpaper):

// Load the image into an int[].
// Here, the image is stored in an embedded resource, and then decoded and resized using SkiaSharp.
// You might have to implement this part, according to your needs.
string imageResourceId = "MaterialColorUtilities.Samples.Assets.5_wallpaper.webp";
using Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageResourceId)!;
SKBitmap bitmap = SKBitmap.Decode(resourceStream).Resize(new SKImageInfo(112, 112), SKFilterQuality.Medium);
int[] pixels = bitmap.Pixels.Select(p => (int)(uint)p).ToArray();

// This is where the magic happens
int seedColor = ImageUtils.ColorFromImage(pixels);

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

CorePalette corePalette = CorePalette.Of(seedColor);
int color = corePalette.Secondary[55];

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

Scheme<int> scheme = new LightScheme(corePalette);
int tertiary = scheme.Tertiary;

A Scheme is generic so you can use any color type. Convert using an extension method:

Scheme<Drawing.Color> dcScheme = scheme.Convert(Drawing.Color.FromArgb);

LightScheme and DarkScheme use the default Material Design 3 mapping of tokens. This can be changed by overriding them:

public class MyScheme : LightScheme
{
    public MyScheme(CorePalette corePalette) : base(corePalette) { }

    protected override int BackgroundLight => Palette.Primary[98];
    protected override int SurfaceLight => Palette.Neutral[100];
    protected override int SurfaceDark => Palette.Neutral[20];
}

For more info check out the source code and the examples.

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on MaterialColorUtilities:

Package Downloads
Material.Components.Maui

Material design Components for .NET MAUI

MaterialColorUtilities.Maui

Material You dynamic theming for .NET MAUI

RichMvvm.MAUI

Package Description

Lamparter.Material

The perfect libary for using Material 3 in MAUI 🎨🖌️

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on MaterialColorUtilities:

Repository Stars
mdc-maui/mdc-maui
Material design components for .NET MAUI
Version Downloads Last updated
0.3.0 26,295 4/11/2023
0.2.0 4,308 11/4/2022
0.1.2 654 8/31/2022
0.1.1 680 7/14/2022
0.1.0 796 4/24/2022
0.0.7 545 4/8/2022
0.0.6 430 3/11/2022
0.0.5 432 3/9/2022