pub struct UvWidget<T: DynamicConsoleDisplay<S>, S: Pixel> { /* private fields */ }Implementations§
Source§impl<S: Pixel, T: DynamicConsoleDisplay<S> + StaticWidget> UvWidget<T, S>
impl<S: Pixel, T: DynamicConsoleDisplay<S> + StaticWidget> UvWidget<T, S>
pub const fn set_uv_x_min(&mut self, val: f32)
pub const fn set_uv_x_max(&mut self, val: f32)
pub const fn set_uv_y_min(&mut self, val: f32)
pub const fn set_uv_y_max(&mut self, val: f32)
pub fn uv_x_to_texture(&self, x: f32) -> usize
pub fn uv_y_to_texture(&self, y: f32) -> usize
pub fn texture_to_uv_x(&self, x: usize) -> f32
pub fn texture_to_uv_y(&self, y: usize) -> f32
Sourcepub fn x_values(&self) -> impl Iterator<Item = f32>
pub fn x_values(&self) -> impl Iterator<Item = f32>
Returns an iterator that contains the uv x coordinates of the underlying display in ascending order.
§Examples
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use console_display::{
widget::single_widget::UvWidget,
pixel_display::StaticPixelDisplay,
pixel::monochrome_pixel::SinglePixel,
};
let mut widget = UvWidget::new(
StaticPixelDisplay::<SinglePixel, 5, 1>::new(
false
)
);
widget.set_uv_x_min(-1.);
widget.set_uv_x_max(2.);
assert_eq!(vec![-0.7, -0.1, 0.5, 1.1, 1.7], widget.x_values().map(|x| (x * 100.).round() / 100.).collect::<Vec<_>>())Sourcepub fn y_values(&self) -> impl Iterator<Item = f32>
pub fn y_values(&self) -> impl Iterator<Item = f32>
Returns an iterator that contains the uv y coordinates of the underlying display in ascending order.
§Examples
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use console_display::{
widget::single_widget::UvWidget,
pixel_display::StaticPixelDisplay,
pixel::monochrome_pixel::SinglePixel,
};
let mut widget = UvWidget::new(
StaticPixelDisplay::<SinglePixel, 1, 5>::new(
false
)
);
widget.set_uv_y_min(-1.);
widget.set_uv_y_max(1.);
assert_eq!(vec![-0.8, -0.4, 0.0, 0.4, 0.8], widget.y_values().map(|y| (y * 100.).round() / 100.).collect::<Vec<_>>())Trait Implementations§
Source§impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> DynamicCanvas<S> for UvWidget<T, S>
impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> DynamicCanvas<S> for UvWidget<T, S>
Source§fn pixel(&self, x: Self::A, y: Self::A) -> Result<<S as Pixel>::U, String>
fn pixel(&self, x: Self::A, y: Self::A) -> Result<<S as Pixel>::U, String>
Gets the pixel at the uv coordinate (x, y). Using coordinates outside the uv mapping is considered undefined behaviour at the moment and is subject to change.
§Errors
Returns an error if the pixel coordinates calculated by the UV mapping are out of bounds.
Source§fn set_pixel(
&mut self,
x: Self::A,
y: Self::A,
value: <S as Pixel>::U,
) -> Result<(), String>
fn set_pixel( &mut self, x: Self::A, y: Self::A, value: <S as Pixel>::U, ) -> Result<(), String>
Sets the pixel at the uv coordinate (x, y).
§Errors
Returns an error if the coordinates are outside the uv mapping.
type A = f32
Source§impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> DynamicWidget for UvWidget<T, S>
impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> DynamicWidget for UvWidget<T, S>
Source§fn width_characters(&self) -> usize
fn width_characters(&self) -> usize
Returns the width of the display in characters.
Source§fn height_characters(&self) -> usize
fn height_characters(&self) -> usize
Returns the height of the display in characters.
Source§fn string_data(&self) -> StringData
fn string_data(&self) -> StringData
Returns a string representation.
The first vector contains rows.
The vectors inside/rows contain individual characters.
Source§impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> SingleWidget<T> for UvWidget<T, S>
impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> SingleWidget<T> for UvWidget<T, S>
Source§impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> StaticWidget for UvWidget<T, S>
impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> StaticWidget for UvWidget<T, S>
Source§const WIDTH_CHARACTERS: usize = <T as StaticWidget>::WIDTH_CHARACTERS
const WIDTH_CHARACTERS: usize = <T as StaticWidget>::WIDTH_CHARACTERS
Width of the display in characters.
Source§const HEIGHT_CHARACTERS: usize = <T as StaticWidget>::HEIGHT_CHARACTERS
const HEIGHT_CHARACTERS: usize = <T as StaticWidget>::HEIGHT_CHARACTERS
Height of the display in characters.
Auto Trait Implementations§
impl<T, S> Freeze for UvWidget<T, S>where
T: Freeze,
impl<T, S> RefUnwindSafe for UvWidget<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for UvWidget<T, S>
impl<T, S> Sync for UvWidget<T, S>
impl<T, S> Unpin for UvWidget<T, S>
impl<T, S> UnwindSafe for UvWidget<T, S>where
T: UnwindSafe,
S: UnwindSafe,
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