MaterialColorUtilities 0.0.6
See the version list below for details.
dotnet add package MaterialColorUtilities --version 0.0.6
NuGet\Install-Package MaterialColorUtilities -Version 0.0.6
<PackageReference Include="MaterialColorUtilities" Version="0.0.6" />
paket add MaterialColorUtilities --version 0.0.6
#r "nuget: MaterialColorUtilities, 0.0.6"
// 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
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 | Versions 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. |
-
.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
|