pub struct Identicon { /* private fields */ }
Expand description
Generic Identicon struct.
This is the base struct to be used.
Implementations§
Source§impl Identicon
impl Identicon
Sourcepub fn new(input_value: &str) -> Identicon
pub fn new(input_value: &str) -> Identicon
Generates a new identicon from an input value.
The defaults are:
- border: 50
- size: 5
- scale: 500
- background_color: (240, 240, 240)
- mirrored: true
Sourcepub fn set_input(&mut self, input_value: &str) -> &mut Self
pub fn set_input(&mut self, input_value: &str) -> &mut Self
Sets the identicon input value, regenerating the hash.
Sourcepub fn set_border(&mut self, border: u32) -> &mut Self
pub fn set_border(&mut self, border: u32) -> &mut Self
Sets the identicon border size.
Default is 5
Sourcepub fn size(&self) -> u32
pub fn size(&self) -> u32
Gets the identicon size.
The size represents the number of viewable blocks of the identicon.
Sourcepub fn set_size(&mut self, size: u32) -> Result<&mut Self, IdenticonError>
pub fn set_size(&mut self, size: u32) -> Result<&mut Self, IdenticonError>
Sets the number of viewable blocks of the identicon.
This must be <= the scale.
Default is 5, representing an identicon with a grid of 5x5.
Sourcepub fn scale(&self) -> u32
pub fn scale(&self) -> u32
Gets the identicon scale.
The scale represents the height and width of the identicon portion of any generated image.
The full image size is: scale + ( 2 * border )
Sourcepub fn set_scale(&mut self, scale: u32) -> Result<&mut Self, IdenticonError>
pub fn set_scale(&mut self, scale: u32) -> Result<&mut Self, IdenticonError>
Sets the scale of the image.
The full image size is: scale + ( 2 * border )
This must be >= the size.
Sourcepub fn set_mirrored(&mut self, mirrored: bool) -> &mut Self
pub fn set_mirrored(&mut self, mirrored: bool) -> &mut Self
Sets whether the identicon is mirrored along the y axis.
This is a boolean.
Sourcepub fn set_theme(&mut self, theme: Arc<dyn Theme + Send + Sync>) -> &mut Self
pub fn set_theme(&mut self, theme: Arc<dyn Theme + Send + Sync>) -> &mut Self
Sets the current identicon theme.
Sourcepub fn generate_image(&self) -> Result<DynamicImage, IdenticonError>
pub fn generate_image(&self) -> Result<DynamicImage, IdenticonError>
Generates the DynamicImage representing the Identicon.
Sourcepub fn save_image(&self, output_filename: &str) -> Result<(), IdenticonError>
pub fn save_image(&self, output_filename: &str) -> Result<(), IdenticonError>
Saves the generated image to the given filename.
The file formats .png
, .jpg
, .jpeg
, .bmp
, and .ico
work.
Sourcepub fn export_png_data(&self) -> Result<Vec<u8>, IdenticonError>
pub fn export_png_data(&self) -> Result<Vec<u8>, IdenticonError>
Export a PNG file buffer as a Vec<u8>
.
This is for creating a file for a buffer or network response without creating a file on the filesystem.
Sourcepub fn export_jpeg_data(&self) -> Result<Vec<u8>, IdenticonError>
pub fn export_jpeg_data(&self) -> Result<Vec<u8>, IdenticonError>
Export a JPEG file buffer as a Vec<u8>
.
This is for creating a file for a buffer or network response without creating a file on the filesystem.