https://github.com/thibseisel/identikon
A Kotlin multiplatform identicon generator library.
https://github.com/thibseisel/identikon
android identicon jvm kotlin
Last synced: 9 months ago
JSON representation
A Kotlin multiplatform identicon generator library.
- Host: GitHub
- URL: https://github.com/thibseisel/identikon
- Owner: thibseisel
- License: apache-2.0
- Created: 2017-11-06T21:54:45.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2022-01-12T19:47:53.000Z (over 4 years ago)
- Last Synced: 2025-04-01T19:11:23.734Z (about 1 year ago)
- Topics: android, identicon, jvm, kotlin
- Language: Kotlin
- Homepage:
- Size: 464 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# identikon
identikon is a Kotlin multiplatform library for generating highly recognizable identicons. It is a
Kotlin port of [Jdenticon](https://github.com/dmester/jdenticon).








## Purpose
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.
## Project status
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+
## Setup
The library is available through MavenCentral. Add the following dependency to your Gradle build
script :
```kotlin
dependencies {
implementation("io.github.thibseisel:identikon:1.0.0")
}
```
## How to use
Create an instance of the `Identicon` class. You have to provide an object whose text representation
will be used to generate the icon.
### Writing icon to an SVG file
```kotlin
// 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)
}
```
### Drawing the icon onto an Android Bitmap
```kotlin
// 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)
```