Struct ratatu_image::picker::Picker
source · pub struct Picker { /* private fields */ }
Implementations§
source§impl Picker
impl Picker
Helper for building widgets
sourcepub fn new(
font_size: FontSize,
backend_type: BackendType,
background_color: Option<Rgb<u8>>
) -> Result<Picker, Box<dyn Error>>
pub fn new( font_size: FontSize, backend_type: BackendType, background_color: Option<Rgb<u8>> ) -> Result<Picker, Box<dyn Error>>
Create a picker from a given terminal FontSize.
Example
use std::io;
use ratatu_image::{
picker::{BackendType, Picker},
Resize,
};
use ratatui::{
backend::{Backend, TestBackend},
layout::Rect,
Terminal,
};
let dyn_img = image::io::Reader::open("./assets/Ada.png").unwrap().decode().unwrap();
let mut picker = Picker::new(
(7, 14),
BackendType::Halfblocks,
None,
).unwrap();
// For FixedImage:
let image_static = picker.new_static_fit(
dyn_img,
Rect::new(0, 0, 15, 5),
Resize::Fit,
).unwrap();
// For ResizeImage:
let image_fit_state = picker.new_state();
sourcepub fn set(&mut self, type: BackendType)
pub fn set(&mut self, type: BackendType)
Set a specific backend
sourcepub fn cycle_backends(&mut self) -> BackendType
pub fn cycle_backends(&mut self) -> BackendType
Cycle through available backends
sourcepub fn new_static_fit(
&mut self,
image: DynamicImage,
size: Rect,
resize: Resize
) -> Result<Box<dyn FixedBackend>, Box<dyn Error>>
pub fn new_static_fit( &mut self, image: DynamicImage, size: Rect, resize: Resize ) -> Result<Box<dyn FixedBackend>, Box<dyn Error>>
Returns a new static backend for crate::FixedImage
widgets that fits into the given size.
sourcepub fn new_state(&mut self) -> Box<dyn ResizeBackend>
pub fn new_state(&mut self) -> Box<dyn ResizeBackend>
Returns a new state backend for crate::ResizeImage
.
pub fn backend_type(&self) -> &BackendType
pub fn font_size(&self) -> FontSize
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Picker
impl Send for Picker
impl Sync for Picker
impl Unpin for Picker
impl UnwindSafe for Picker
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more