UvWidget

Struct UvWidget 

Source
pub struct UvWidget<T: DynamicConsoleDisplay<S>, S: Pixel> { /* private fields */ }

Implementations§

Source§

impl<T: DynamicConsoleDisplay<S>, S: Pixel> UvWidget<T, S>

Source

pub fn new(child: T) -> Self

Source§

impl<S: Pixel, T: DynamicConsoleDisplay<S> + StaticWidget> UvWidget<T, S>

Source

pub const fn set_uv_x_min(&mut self, val: f32)

Source

pub const fn set_uv_x_max(&mut self, val: f32)

Source

pub const fn set_uv_y_min(&mut self, val: f32)

Source

pub const fn set_uv_y_max(&mut self, val: f32)

Source

pub fn uv_x_to_texture(&self, x: f32) -> usize

Source

pub fn uv_y_to_texture(&self, y: f32) -> usize

Source

pub fn texture_to_uv_x(&self, x: usize) -> f32

Source

pub fn texture_to_uv_y(&self, y: usize) -> f32

Source

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<_>>())
Source

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>, S: Pixel> Deref for UvWidget<T, S>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: DynamicConsoleDisplay<S>, S: Pixel> DerefMut for UvWidget<T, S>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

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>
where [(); { _ }]:,

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>
where [(); { _ }]:,

Sets the pixel at the uv coordinate (x, y).

§Errors

Returns an error if the coordinates are outside the uv mapping.

Source§

type A = f32

Source§

fn draw<D: DynamicDrawable<N>, const N: usize>( &mut self, drawable: &D, value: <S as Pixel>::U, )
where Self: Sized, [(); { _ }]:,

Draw a drawable/shape onto a canvas with the specified pixel type/brush. Convenience method for inversing DynamicDrawable::draw by using double dispatch.
Source§

impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> DynamicWidget for UvWidget<T, S>

Source§

fn width_characters(&self) -> usize

Returns the width of the display in characters.
Source§

fn height_characters(&self) -> usize

Returns the height of the display in characters.
Source§

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>

Source§

type Borrowed<'a> = &'a T where T: 'a, S: 'a

Source§

type BorrowedMut<'a> = &'a mut T where T: 'a, Self: 'a

Source§

fn child(&self) -> &T

Source§

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

Source§

impl<T: DynamicConsoleDisplay<S> + StaticWidget, S: Pixel> StaticWidget for UvWidget<T, S>

Source§

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

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>

§

impl<T, S> Send for UvWidget<T, S>
where T: Send, S: Send,

§

impl<T, S> Sync for UvWidget<T, S>
where T: Sync, S: Sync,

§

impl<T, S> Unpin for UvWidget<T, S>
where T: Unpin, S: Unpin,

§

impl<T, S> UnwindSafe for UvWidget<T, S>
where T: UnwindSafe, S: UnwindSafe,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.