Struct captcha::Captcha
[−]
[src]
pub struct Captcha { /* fields omitted */ }
Used to build a CAPTCHA step by step.
Methods
impl Captcha
[src]
fn new() -> Captcha
Returns an empty CAPTCHA.
fn apply_filter<F: Filter>(&mut self, f: F) -> &mut Self
Applies the filter f
to the CAPTCHA.
This method is used to add noise, grids, etc or to transform the shape of the CAPTCHA.
fn set_font<F: Font + 'static>(&mut self, f: F) -> &mut Self
Sets another font that is used for the characters.
Calling this method does not have an effect on the font of the characters which have already been added to the CAPTCHA. The new font is only applied to the characters which are written to the CAPTCHA after this method is called.
fn save(&self, p: &Path) -> Result<()>
Saves the CAPTCHA to a image file.
The format that is written is determined from the filename's extension. On error Err
is
returned.
fn add_char(&mut self) -> &mut Self
Adds a random character using the current font.
fn add_text_area(&mut self) -> &mut Self
Adds a red box to the CAPTCHA representing the area which contains text.
fn text_area(&self) -> Geometry
Returns the geometry of the area which contains text in the CAPTCHA.
fn extract(&mut self, area: Geometry) -> &mut Self
Crops the CAPTCHA to the given geometry.
fn view(&mut self, w: u32, h: u32) -> &mut Self
Crops the CAPTCHA to the given width and height with the text centered withing this box.
fn chars(&self) -> Vec<char>
Returns the characters added to this CAPTCHA.
fn add_chars(&mut self, n: u32) -> &mut Self
Adds the given number of random characters to the CAPTCHA using the current font.
fn as_png(&self) -> Option<Vec<u8>>
Returns the CAPTCHA as a png image.
Returns None
on error.