Jdenticon-net
2.0.0
See the version list below for details.
dotnet add package Jdenticon-net --version 2.0.0
NuGet\Install-Package Jdenticon-net -Version 2.0.0
<PackageReference Include="Jdenticon-net" Version="2.0.0" />
paket add Jdenticon-net --version 2.0.0
#r "nuget: Jdenticon-net, 2.0.0"
// Install Jdenticon-net as a Cake Addin #addin nuget:?package=Jdenticon-net&version=2.0.0 // Install Jdenticon-net as a Cake Tool #tool nuget:?package=Jdenticon-net&version=2.0.0
Jdenticon-net
.NET library for generating highly recognizable identicons.
Features
Jdenticon-net is a .NET port of the JavaScript library Jdenticon.
- Runs on .NET Framework 2.x, 3.x, 4.x, .NET Standard 1.x and .NET Core 1.x.
- Render icons as PNG and SVG files with no dependencies to System.Drawing or WPF.
- Integration package available for ASP.NET WebForms, MVC and WebApi.
- Generate SVG fragments to be used inline on websites.
- Render icons directly on screen using GDI+.
Getting started
Using Jdenticon-net is simple. Follow the steps below to integrate Jdenticon-net into your solution.
1. Install the NuGet package
PM> Install-Package Jdenticon-net
2. Use Identicon
to generate icons
using Jdenticon;
----
var icon = Identicon.FromValue("john.doe@example.faux", size: 100);
icon.SaveAsPng("johndoe.png");
ASP.NET
To get started using Jdenticon for ASP.NET, please see:
Quick Reference
For full documentation, please see https://dmester.github.io/jdenticon-net-docs/.
Create an instance of Identicon
There are mainly two ways of creating an instance of Identicon
:
Identicon.FromHash(hash, size)
Creates an instance with a hash value. You can either provide a byte array containing the hash, or provide a hexadecimal hash string. At least 6 bytes are required in byte arrays and 12 characters in hash strings.
Identicon.FromValue(value, size[, hashAlgorithmName])
Jdenticon-net will create a hash for you using the specified hash algorithm. You can provide any object, even null, as argument. Jdenticon will use
ToString
to get a string representation of the object and then push the UTF8-encoded string through the specified hash algorithm. If no hash algorithm is specified Jdenticon-net will default to SHA1.
Generate an icon
There are multiple methods in the Identicon
class for generating icons:
SaveAsPng(path|stream)
Generates an icon and saves it as a PNG image.
SaveAsSvg(path|stream|TextWriter)
Generates an icon and saves it as an SVG image.
Draw(graphics, rectangle)
Generates an icon and draws it in the specified GDI+ drawing context. Suitable if you want to display the icon on the screen without first saving it to a file.
ToBitmap()
Generates an icon as a Bitmap object for later usage. Remember that you are responsible for disposing the returned object when you don't need it anymore.
ToSvg([fragment])
Generates an SVG string containing an icon. This can be useful for embedding icons in other SVG files or inlining SVG icons on your website. For creating SVG files, please use
Save
.
Change icon appearance
There are properties on Identicon
that can be used to customize the look of the generated icons.
Style.Padding
(default 0.08)The padding between the outer bounds of the icon and the content. Specified as percent in the range [0.0, 0.4].
Style.BackColor
(default white)Specifies the background color of the generated icon. Set to
Color.Transparent
to not render any background behind the identicon shapes.Style.Saturation
(default 0.5)Saturation of colored shapes in the range [0.0, 1.0].
Style.ColorLightness
(default [0.4, 0.8])Lightness range of colored shapes in the range [0.0, 1.0]. The lightness of the shapes can be inverted by specifying a range where
Range.From
is greater thanRange.To
.Style.GrayscaleLightness
(default [0.3, 0.9])Lightness range of grayscale shapes in the range [0.0, 1.0]. The lightness of the shapes can be inverted by specifying a range where
Range.From
is greater thanRange.To
.
Example
using Jdenticon;
using Jdenticon.Rendering;
----
var iconStyle = new IdenticonStyle
{
Padding = 0.10f,
BackColor = Color.Transparent,
Saturation = 0.4f,
ColorLightness = Range.Create(0.4f, 0.9f),
GrayscaleLightness = Range.Create(0.3f, 0.9f)
};
var icon = Identicon.FromValue("john.doe@example.faux", size: 100);
icon.Style = iconStyle;
icon.SaveAsPng("johndoe.png");
Advanced customizations
By subclassing Jdenticon.IconGenerator
you can completely override the look of your icons. Set the
Identicon.IconGenerator
property to an instance of your own generator to make use of the customized
icon generator.
License
Jdenticon-net is released under the MIT license.
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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net20 is compatible. net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 0.0
- No dependencies.
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.0)
- SharpCompress (>= 0.13.0)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.0)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on Jdenticon-net:
Package | Downloads |
---|---|
Jdenticon.AspNetCore
Extends Jdenticon-net with features to use Jdenticon with ASP.NET Core. This package contains: * IdenticonTagHelper * @Html.Identicon() extension method * @Url.Identicon() extension method * IdenticonResult for usage in MVC controllers |
|
Jdenticon.Gdi
This is a dependency to Jdenticon.WinForms. You probably want to install the Jdenticon.WinForms package instead. This package can on its own be used to: * Render identicons to System.Drawing.Graphics * Render identicons to System.Drawing.Bitmap * Render EMF (Enhanced Metafile) identicons This package is not intended for server-side applications. |
|
Jdenticon.AspNet.Mvc
Extends Jdenticon-net with features to use Jdenticon with ASP.NET MVC. This package contains: * @Html.Identicon() extension method * @Url.Identicon() extension method * IdenticonResult for usage in MVC controllers |
|
Jdenticon.AspNet.WebApi
Extends Jdenticon-net with features to use Jdenticon with ASP.NET WebApi. This package contains: * IdenticonResult for usage in WebApi controllers |
|
Jdenticon.Wpf
Extends Jdenticon-net with features to use Jdenticon with WPF. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on Jdenticon-net:
Repository | Stars |
---|---|
IoTSharp/IoTSharp
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
|
|
EverestAPI/Everest
Everest - Celeste Mod Loader / Mod API
|
|
LukeEmmet/GemiNaut
GemiNaut - A friendly Gemini client for Windows
|