pub struct View {
pub source_x: u32,
pub source_y: u32,
pub source_width: u32,
pub source_height: u32,
pub target_width: u32,
pub target_height: u32,
}Expand description
Defines the mapping between a rectangular area of the source image and the target rendering area in the terminal.
The View struct is used to determine which pixels from the source image
correspond to which character cells in the terminal output.
Fields§
§source_x: u32The top-left X coordinate of the view on the source image (in pixels).
source_y: u32The top-left Y coordinate of the view on the source image (in pixels).
source_width: u32The width of the view on the source image (in pixels).
source_height: u32The height of the view on the source image (in pixels).
target_width: u32The width of the target render area (in terminal columns).
target_height: u32The height of the target render area (in terminal rows).
Implementations§
Source§impl View
impl View
Sourcepub fn calculate_scaling(&self) -> (f32, f32)
pub fn calculate_scaling(&self) -> (f32, f32)
Calculates the scaling ratios between source and target dimensions.
§Returns
A tuple (x_ratio, y_ratio) representing source pixels per terminal cell.
Sourcepub fn map_to_source(
&self,
x: u32,
y: u32,
x_ratio: f32,
y_ratio: f32,
) -> (u32, u32, u32)
pub fn map_to_source( &self, x: u32, y: u32, x_ratio: f32, y_ratio: f32, ) -> (u32, u32, u32)
Maps a terminal cell coordinate (x, y) to the corresponding source image coordinates.
§Arguments
x- The terminal column index.y- The terminal row index.x_ratio- Source pixels per column.y_ratio- Source pixels per row.
§Returns
A tuple (source_x, source_y_top, source_y_bottom) representing the starting
pixel coordinates for the top and bottom halves of the character block.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for View
impl RefUnwindSafe for View
impl Send for View
impl Sync for View
impl Unpin for View
impl UnsafeUnpin for View
impl UnwindSafe for View
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
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>
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>
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