Struct initials::avatar::AvatarBuilder
source · pub struct AvatarBuilder {
pub name: String,
pub font_data: Vec<u8>,
pub font_scale: Scale,
pub font_color: Vec<i64>,
pub background_color: Vec<i64>,
pub length: usize,
pub width: u32,
pub height: u32,
pub contrast_ratio: f32,
/* private fields */
}
Expand description
Avatar builder that stores the metrics of the image.
Fields
name: String
Initials name string
font_data: Vec<u8>
Vectorized font data
font_scale: Scale
Scale of the font
font_color: Vec<i64>
RGB color of the font
background_color: Vec<i64>
RGB color of the background
length: usize
Size of the inner-text
width: u32
Width of the avatar
height: u32
Height of the avatar
contrast_ratio: f32
Contrast ratio for the colors
Implementations
sourceimpl AvatarBuilder
impl AvatarBuilder
sourcepub fn new(name: &str) -> AvatarBuilder
pub fn new(name: &str) -> AvatarBuilder
Construct new AvatarBuilder.
sourcepub fn with_font(self, font: &str) -> AvatarResult
pub fn with_font(self, font: &str) -> AvatarResult
Change the font of the avatar text. You need to include .ttf
file.
Default style is Hiragino_Sans
.
sourcepub fn with_font_color(self, color: &str) -> AvatarResult
pub fn with_font_color(self, color: &str) -> AvatarResult
Change the font color. You need to specify hex color code.
sourcepub fn with_font_scale(self, scale: f32) -> AvatarResult
pub fn with_font_scale(self, scale: f32) -> AvatarResult
Change the uniform scale of font.
Default to 150.0
.
sourcepub fn with_background_color(self, color: &str) -> AvatarResult
pub fn with_background_color(self, color: &str) -> AvatarResult
Change the background color of the avatar. You need to specify hex color code.
sourcepub fn with_length(self, length: usize) -> AvatarResult
pub fn with_length(self, length: usize) -> AvatarResult
Change the length of initials characters taken from the name.
Default to 2
.
sourcepub fn with_width(self, width: u32) -> AvatarResult
pub fn with_width(self, width: u32) -> AvatarResult
Change the width of the avatar.
Default to 300
.
sourcepub fn with_height(self, height: u32) -> AvatarResult
pub fn with_height(self, height: u32) -> AvatarResult
Change the height of the avatar.
Default to 300
.
sourcepub fn with_contrast_ratio(self, ratio: f32) -> AvatarResult
pub fn with_contrast_ratio(self, ratio: f32) -> AvatarResult
Change the contrast ratio for the randomly generated avatar.
Default to 4.5
. Increase the ratio for more clear avatar.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AvatarBuilder
impl Send for AvatarBuilder
impl Sync for AvatarBuilder
impl Unpin for AvatarBuilder
impl UnwindSafe for AvatarBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
value
as a parameter of self
.