identikon is a Kotlin multiplatform library for generating highly recognizable identicons. It is a Kotlin port of Jdenticon.
An Identicon is a visual representation of a hash value, usually of an IP address, that serves to identify a user of a computer system as a form of avatar while protecting the users' privacy.
You may also use these icons in any other context, for example as a placeholder image.
identikon has just released it's first version. More features may be added at a later time. The following features are currently available:
- save icons as SVG,
- draw icons on an Android
Bitmap
This library is currently supporting the following platforms:
- JVM 11+
- Android API 21+
The library is available through MavenCentral. Add the following dependency to your Gradle build script :
dependencies {
implementation("io.github.thibseisel:identikon:1.0.0")
}
Create an instance of the Identicon
class. You have to provide an object whose text representation
will be used to generate the icon.
// Create a new instance of the Identicon class with an hash string and the given size
val icon = Identicon.fromValue("Hello World!", iconSize = 300)
// Writes the icon to a SVG file
Path("my-icon.svg").outputStream().use {
icon.saveAsSvg(it)
}
// Create a new instance of the Identicon class with an hash string and the given size
val icon = Identicon.fromValue("Hello World!", iconSize = 300)
// Start the rendering
val targetBitmap = Bitmap.createBitmap(128, 128, Bitmap.Config.ARGB_8888)
icon.drawToBitmap(targetBitmap)