Visual

Struct Visual 

Source
pub struct Visual { /* private fields */ }
Expand description

A visual bit of multimedia.

Implementations§

Source§

impl Visual

§Visual constructors and deconstructors.

Source

pub fn builder() -> VisualBuilder

Returns a new Visual builder.

Source

pub fn from_rgba( nc: &Notcurses, rgba: &[u8], size: impl Into<Size>, ) -> Result<Visual>

Returns a new Visual from a byte buffer with RGBA content.

Source

pub fn from_rgb( nc: &Notcurses, rgb: &[u8], size: impl Into<Size>, alpha: u8, ) -> Result<Visual>

Builds a new Visual from a byte buffer with RGB content, providing the alpha to assign to all the pixels.

Source

pub fn from_rgbx( nc: &Notcurses, rgbx: &[u8], size: impl Into<Size>, alpha: u8, ) -> Result<Visual>

Builds a new Visual from a byte buffer with RGBX content, overriding the alpha byte X for all the pixels.

Source

pub fn from_bgra( nc: &Notcurses, bgra: &[u8], size: impl Into<Size>, ) -> Result<Visual>

Builds a new Visual from a byte buffer with BGRA content.

This is slower than build_from_rgba, since it has to convert the pixels to the rgba format used internally.

Source

pub fn from_file(nc: &Notcurses, file: &str) -> Result<Visual>

Builds a new Visual from a file, extracts the codec and parameters and decodes the first image to memory.

It needs notcurses to be compiled with multimedia capabilities.

Source

pub fn from_plane( plane: &Plane, blitter: Blitter, beg_x: Option<u32>, beg_y: Option<u32>, len_x: Option<u32>, len_y: Option<u32>, ) -> Result<Visual>

Builds a new Visual from a Plane.

The plane may contain only spaces, half blocks, and full blocks. This will be checked, and any other glyph will result in an error.

This function exists so that planes can be subjected to Visual transformations. If possible, it’s better to build the visual from memory using build_from_rgba.

Use None for either or both of beg_y and beg_x in order to use the current cursor position along that axis.

Use None for either or both of len_y and len_x in order to go through the boundary of the plane in that axis (same as 0).

Source

pub fn into_ref(&self) -> &NcVisual

Returns a shared reference to the inner NcVisual.

Source

pub fn into_ref_mut(&mut self) -> &mut NcVisual

Returns an exclusive reference to the inner NcVisual.

Source

pub fn options(&self) -> VisualOptions

Returns the visual options.

Source

pub fn set_options(&mut self, options: VisualOptions)

Sets the visual options.

Source§

impl Visual

§Visual methods.

Source

pub fn blit(&mut self, notcurses: &Notcurses) -> Result<Plane>

Renders the Visual to a new Plane, which is returned.

Source

pub fn blit_plane( &mut self, notcurses: &Notcurses, target: &mut Plane, ) -> Result<()>

Renders the Visual to an existing target Plane.

Source

pub fn blit_child( &mut self, notcurses: &Notcurses, parent: &mut Plane, ) -> Result<Plane>

Renders the Visual to a new child Plane of a parent plane, which is returned.

Source

pub fn geometry(&self, notcurses: &Notcurses) -> Result<VisualGeometry>

Returns the visual geometry.

Source

pub fn size(&self) -> Result<Size>

Returns the internal size of the visual, in pixels.

Source

pub fn resize(&mut self, size: Size) -> Result<()>

Resizes the visual to the new size using bilinear interpolation.

This is a lossy transformation, unless the size is unchanged.

Source

pub fn resize_nearest(&mut self, size: Size) -> Result<()>

Resizes the visual to the new size using nearest neighbor interpolation.

This is a lossy transformation, unless the size is unchanged.

Source

pub fn rotate(&mut self, radians: f64) -> Result<()>

Rotates the visual a number of radians.

Only M_PI/2 and -M_PI/2 are supported at the moment.

Source

pub fn set_x(&mut self, x: i32)

Sets the horizontal placement, overriding horizontal alignment.

Default: 0.

Source

pub fn set_y(&mut self, y: i32)

Sets the vertical placement, overriding vertical alignment.

Default: 0.

Source

pub fn set_xy(&mut self, x: i32, y: i32)

Sets both the horizontal & vertical placement, overriding both horizontal & vertical alignment.

Default: (0, 0).

Source

pub fn set_position(&mut self, position: Position)

Convenience wrapper around set_yx.

Source

pub fn set_halign(&mut self, horizontal: Align)

Sets the horizontal alignment.

Default: Align::Left.

Source

pub fn set_valign(&mut self, vertical: Align)

Sets the vertical alignment.

Default: Align::Top.

Source

pub fn set_align(&mut self, vertical: Align, horizontal: Align)

Sets both the vertical & horizontal alignment.

Default: (Align::Top, Align::Left).

Source

pub fn set_scale(&mut self, scale: Scale)

Sets the Scale.

Default: Scale::None.

Source

pub fn set_blitter(&mut self, blitter: Blitter)

Sets the Blitter.

Default: Blitter::Default.

Source

pub fn set_blitter_pixel(&mut self)

Sets the Pixel blitter.

Source

pub fn get_pixel(&self, x: u32, y: u32) -> Result<Rgba>

Gets the Rgba pixel at the provided coordinates.

Corresponds to NcVisual::at_yx.

Source

pub fn set_pixel(&mut self, x: u32, y: u32, rgba: impl Into<Rgba>) -> Result<()>

Sets the Rgba pixel at the provided coordinates.

Corresponds to NcVisual::set_yx.

Source

pub fn set_degrade(&mut self, degrade: bool)

(Un)Sets graful degradation.

Choose between gracefully degrading the blitter, or fail if the choosen Blitter is not supported by the terminal.

Default: true (degrade).

Source

pub fn set_transparency(&mut self, color: Option<Rgba>)

(Un)Sets this color as transparent.

Default: None.

Source

pub fn set_blend(&mut self, blend: bool)

(Un)Sets alpha blending.

Choose whether to use Alpha::Blend with the Visual, so that the foreground or background colors can be a composite between a color and the corresponding colors underneath it.

Default: false (no blend).

Source

pub fn set_interpolate(&mut self, interpolate: bool)

(Un)Sets scaling interpolation.

Default: true (interpolate).

Source

pub fn set_region(&mut self, x: u32, y: u32, len_x: u32, len_y: u32)

Sets the region to be rendered.

  • y, x: origin of the rendered region in pixels.
  • len_y, len_x: size of the rendered region in pixels.
Source

pub fn set_cell_offset(&mut self, x: u32, y: u32)

Sets the pixel offset within the Cell.

Trait Implementations§

Source§

impl Debug for Visual

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Visual

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Visual

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Visual

§

impl !RefUnwindSafe for Visual

§

impl !Send for Visual

§

impl !Sync for Visual

§

impl Unpin for Visual

§

impl !UnwindSafe for Visual

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<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.