Insa

Struct Insa 

Source
pub struct Insa { /* private fields */ }
Expand description

The main interface to image to text converion

Implementations§

Source§

impl Insa

Source

pub fn plain() -> Insa

Initialize using just space brush, no fixed background.

Source

pub fn simple_on_dark() -> Insa

Initialize using well known round chars on dark background

Source

pub fn simple_on_bright() -> Insa

Initialize using well known round chars on dark background

Source

pub fn blocks() -> Insa

Initialize using well known block drawing elements and using background

Source

pub fn load_brushes( &mut self, font: &Font, brushes: impl AsRef<str>, ) -> &mut Self

Load additional brushes from a font

let font = include_bytes!("../docs/unifont-15.0.01.ttf");
let font = fontdue::Font::from_bytes(font.as_ref(), fontdue::FontSettings::default())
 .expect("tried and tested included font");
let mut insa = insa::Insa::default();
insa.load_brushes(&font, ".oO8°");
println!("{insa:?}")
Source

pub fn brushes(&self) -> &BrushMap

ref access the internal brush map

Source

pub fn brushes_mut(&mut self) -> &mut BrushMap

Mut access internal brush map

Source

pub fn invert(&self) -> bool

Does Insa invert dark/light?

Source

pub fn invert_mut(&mut self) -> &mut bool

Mut access to - does Insa invert dark/light?

Source

pub fn set_invert(&mut self, invert: bool) -> &mut Self

Should Insa invert dark/light?

Source

pub fn fixed_background(&self) -> Option<(u8, u8, u8)>

Does Insa invert dark/light?

Source

pub fn fixed_background_mut(&mut self) -> Option<&mut (u8, u8, u8)>

Mut access to - does Insa invert dark/light?

Source

pub fn set_fixed_background( &mut self, invert: Option<(u8, u8, u8)>, ) -> &mut Self

Should Insa invert dark/light?

Source

pub fn brush_width(&self) -> u8

The width of the brush in pixels

Source

pub fn brush_height(&self) -> u8

The height of the brush in pixels

Source

pub fn convert<'a>(&'a self, img: &'a DynamicImage) -> ConvertIterator<'a>

Convert a raster bitmap image to text. The returned iterator reveals the number of text columns and rows

Source

pub fn convert_symbol(&self, img: &SubImage<&DynamicImage>) -> Symbol

Convert a single symbol, assuming position 0,0 and the symbol width and height for input

Trait Implementations§

Source§

impl Debug for Insa

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Insa

Source§

fn default() -> Insa

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Insa

§

impl RefUnwindSafe for Insa

§

impl Send for Insa

§

impl Sync for Insa

§

impl Unpin for Insa

§

impl UnwindSafe for Insa

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.