pub struct ImageSource {
pub image: DynamicImage,
pub font_size: FontSize,
pub desired: Rect,
pub hash: u64,
}Expand description
Image source for crate::backend::ResizeBackends
A [ResizeBackend] needs to resize the ImageSource to its state when the available area
changes. A [FixedBackend] only needs it once.
§Examples
use image::{DynamicImage, ImageBuffer, Rgb};
use ratatu_image::ImageSource;
let image: ImageBuffer::from_pixel(300, 200, Rgb::<u8>([255, 0, 0])).into();
let source = ImageSource::new(image, "filename.png", (7, 14));
assert_eq!((43, 14), (source.rect.width, source.rect.height));Fields§
§image: DynamicImageThe original image without resizing
font_size: FontSizeThe font size of the terminal
desired: RectThe area that the ImageSource::image covers, but not necessarily fills
hash: u64Implementations§
Source§impl ImageSource
impl ImageSource
Sourcepub fn new(image: DynamicImage, font_size: FontSize) -> ImageSource
pub fn new(image: DynamicImage, font_size: FontSize) -> ImageSource
Create a new image source
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ImageSource
impl RefUnwindSafe for ImageSource
impl Send for ImageSource
impl Sync for ImageSource
impl Unpin for ImageSource
impl UnsafeUnpin for ImageSource
impl UnwindSafe for ImageSource
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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