Struct identicon_rs::Identicon
source · [−]pub struct Identicon { /* private fields */ }
Expand description
Generic Identicon struct
This is the base struct to be used.
Implementations
sourceimpl Identicon
impl Identicon
sourcepub fn new<T>(input_value: T) -> Self where
T: AsRef<str>,
pub fn new<T>(input_value: T) -> Self where
T: AsRef<str>,
Generates a new identicon
The defaults are:
- border: 50
- size: 5
- scale: 500
- background_color: (240, 240, 240)
- mirrored: true
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 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 5x5
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 scale plus 2 times the border is the final pixel size of the image.
This must be >= the size.
Default is 500
sourcepub fn background_color(&self) -> (u8, u8, u8)
pub fn background_color(&self) -> (u8, u8, u8)
Gets the identicon background color
sourcepub fn set_background_color(
&mut self,
background_color: (u8, u8, u8)
) -> &mut Self
pub fn set_background_color(
&mut self,
background_color: (u8, u8, u8)
) -> &mut Self
Sets the background, non-active color of the identicon.
This is a tuble of (red, green, blue) values.
Default is (240, 240, 240)
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.
Default is true
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
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
This is for creating a file for a buffer or network response without creating a file on the filesystem.
Trait Implementations
sourceimpl Ord for Identicon
impl Ord for Identicon
sourceimpl PartialOrd<Identicon> for Identicon
impl PartialOrd<Identicon> for Identicon
sourcefn partial_cmp(&self, other: &Identicon) -> Option<Ordering>
fn partial_cmp(&self, other: &Identicon) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Identicon
impl StructuralEq for Identicon
impl StructuralPartialEq for Identicon
Auto Trait Implementations
impl RefUnwindSafe for Identicon
impl Send for Identicon
impl Sync for Identicon
impl Unpin for Identicon
impl UnwindSafe for Identicon
Blanket Implementations
sourceimpl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
sourcefn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified method Read more
sourcefn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford method by default Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, U> IntoColor<U> for T where
U: FromColor<T>,
impl<T, U> IntoColor<U> for T where
U: FromColor<T>,
sourcefn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
sourceimpl<T, U> IntoColorUnclamped<U> for T where
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for T where
U: FromColorUnclamped<T>,
sourcefn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T, U> TryIntoColor<U> for T where
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for T where
U: TryFromColor<T>,
sourcefn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an OutOfBounds
error is returned which contains
the unclamped color. Read more