robohash

Crates.iorobohash
lib.rsrobohash
version0.2.3
sourcesrc
created_at2022-12-05 16:55:01.807009
updated_at2022-12-09 11:45:13.582687
descriptionRoboHash implementation
homepagehttps://github.com/kyco/robohash
repositoryhttps://github.com/kyco/robohash
max_upload_size
id730468
size25,819
Kyluke (kyluke)

documentation

README

RoboHash

Rust implementation of RoboHash by e1ven

Install

robohash = "0.2.3"

Example Implementation

use std::fmt::Error;
use robohash::RoboHashBuilder;

fn main() -> Result<(), Error> {
    let text = "test";
    let robo = RoboHashBuilder::new(text).build();
    let robo_hash = robo.assemble_base64()?;
    println!("{robo_hash:#?}");
    Ok(())
}

Define Size

let width = 512;
let height = 512;
let robo = RoboHashBuilder::new("test")
.with_size(width, height)
.build();

Define Colour

let robo = RoboHashBuilder::new("test")
.with_colour("green")
.build();

Define Set

let robo = RoboHashBuilder::new("test")
.with_set("set3")
.build();

Change Sets Directory

let robo = RoboHashBuilder::new("test")
.with_set_location("./sets_location")
.build();

Define Background

let robo = RoboHashBuilder::new("test")
.with_background_set("bg1")
.build();

Change Background Directory

let robo = RoboHashBuilder::new("test")
.with_background_location("./backgrounds")
.build();

Full Example

use std::fmt::Error;
use robohash::RoboHashBuilder;

fn main() -> Result<(), Error> {
    let text = "test";
    let robo = RoboHashBuilder::new(text)
        .with_set("set1")
        .with_colour("green")
        .with_set_location("./sets-root")
        .with_background_set("bg1")
        .with_background_location("./backgrounds")
        .with_size(512, 512)
        .build();
    let robo_hash = robo.assemble_base64()?;
    println!("{robo_hash:#?}");
    Ok(())
}

Implemented

  • Generate base64 robo hash image from any of the provided sets and colours
  • Background support
  • Image size support

Todo

  • Support backgrounds
  • Support for saving images to disk
  • Support for returning raw image data
  • Support image sizing
Commit count: 28

cargo fmt