Crates.io | identicons-svg |
lib.rs | identicons-svg |
version | 0.1.0 |
source | src |
created_at | 2022-09-16 16:23:24.504458 |
updated_at | 2022-09-16 16:23:24.504458 |
description | A crate to quickly generate identicons avatar pictures. |
homepage | |
repository | |
max_upload_size | |
id | 667496 |
size | 13,559 |
Rust crate to quickly generate identicon avatar svgs.
Generate a new svg containing the identicon, given a size, a width and a hexadecimal string.
This crate is basically a port from identicons, a Javascript library written by Bryce Wilson.
While the original library allows for various types of identicon, such as square, polygon and circle, this library allows only the square type. Another difference is that while the original library obtained the icon color from the hash, this crate uses random_color to generate a more bright and visually-pleasing color.
This will generate a new identicon. The size of the new svg will be between 4x4 and 8x8 (always a square), the width will be 128, the color will be randomly chosen.
Identicons are made from hex hashes and you can provide one yourself. This is not a means of encryption and you should not be using data relative to the user. That's why by default the hex hash is randomly generated. A function to create random hex hashes is also available.
use identicons_svg::generate;
let svg: String = generate(IdenticonOptions::default())
// svg will be a valid xml string, it could be saved to a file or displayed in a web page