pub struct Visual { /* private fields */ }Expand description
A visual bit of multimedia.
Implementations§
Source§impl Visual
§Visual constructors and deconstructors.
impl Visual
§Visual constructors and deconstructors.
Sourcepub fn builder() -> VisualBuilder
pub fn builder() -> VisualBuilder
Returns a new Visual builder.
Sourcepub fn from_rgba(
nc: &Notcurses,
rgba: &[u8],
size: impl Into<Size>,
) -> Result<Visual>
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.
Sourcepub fn from_rgb(
nc: &Notcurses,
rgb: &[u8],
size: impl Into<Size>,
alpha: u8,
) -> Result<Visual>
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.
Sourcepub fn from_rgbx(
nc: &Notcurses,
rgbx: &[u8],
size: impl Into<Size>,
alpha: u8,
) -> Result<Visual>
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.
Sourcepub fn from_bgra(
nc: &Notcurses,
bgra: &[u8],
size: impl Into<Size>,
) -> Result<Visual>
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.
Sourcepub fn from_file(nc: &Notcurses, file: &str) -> Result<Visual>
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.
Sourcepub 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>
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).
Sourcepub fn into_ref_mut(&mut self) -> &mut NcVisual
pub fn into_ref_mut(&mut self) -> &mut NcVisual
Returns an exclusive reference to the inner NcVisual.
Sourcepub fn options(&self) -> VisualOptions
pub fn options(&self) -> VisualOptions
Returns the visual options.
Sourcepub fn set_options(&mut self, options: VisualOptions)
pub fn set_options(&mut self, options: VisualOptions)
Sets the visual options.
Source§impl Visual
§Visual methods.
impl Visual
§Visual methods.
Sourcepub fn blit(&mut self, notcurses: &Notcurses) -> Result<Plane>
pub fn blit(&mut self, notcurses: &Notcurses) -> Result<Plane>
Renders the Visual to a new Plane, which is returned.
Sourcepub fn blit_plane(
&mut self,
notcurses: &Notcurses,
target: &mut Plane,
) -> Result<()>
pub fn blit_plane( &mut self, notcurses: &Notcurses, target: &mut Plane, ) -> Result<()>
Renders the Visual to an existing target Plane.
Sourcepub fn blit_child(
&mut self,
notcurses: &Notcurses,
parent: &mut Plane,
) -> Result<Plane>
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.
Sourcepub fn geometry(&self, notcurses: &Notcurses) -> Result<VisualGeometry>
pub fn geometry(&self, notcurses: &Notcurses) -> Result<VisualGeometry>
Returns the visual geometry.
Sourcepub fn resize(&mut self, size: Size) -> Result<()>
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.
Sourcepub fn resize_nearest(&mut self, size: Size) -> Result<()>
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.
Sourcepub fn rotate(&mut self, radians: f64) -> Result<()>
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.
Sourcepub fn set_x(&mut self, x: i32)
pub fn set_x(&mut self, x: i32)
Sets the horizontal placement, overriding horizontal alignment.
Default: 0.
Sourcepub fn set_y(&mut self, y: i32)
pub fn set_y(&mut self, y: i32)
Sets the vertical placement, overriding vertical alignment.
Default: 0.
Sourcepub fn set_xy(&mut self, x: i32, y: i32)
pub fn set_xy(&mut self, x: i32, y: i32)
Sets both the horizontal & vertical placement, overriding both horizontal & vertical alignment.
Default: (0, 0).
Sourcepub fn set_position(&mut self, position: Position)
pub fn set_position(&mut self, position: Position)
Convenience wrapper around set_yx.
Sourcepub fn set_halign(&mut self, horizontal: Align)
pub fn set_halign(&mut self, horizontal: Align)
Sets the horizontal alignment.
Default: Align::Left.
Sourcepub fn set_valign(&mut self, vertical: Align)
pub fn set_valign(&mut self, vertical: Align)
Sets the vertical alignment.
Default: Align::Top.
Sourcepub fn set_align(&mut self, vertical: Align, horizontal: Align)
pub fn set_align(&mut self, vertical: Align, horizontal: Align)
Sets both the vertical & horizontal alignment.
Default: (Align::Top, Align::Left).
Sourcepub fn set_blitter(&mut self, blitter: Blitter)
pub fn set_blitter(&mut self, blitter: Blitter)
Sets the Blitter.
Default: Blitter::Default.
Sourcepub fn set_blitter_pixel(&mut self)
pub fn set_blitter_pixel(&mut self)
Sets the Pixel blitter.
Sourcepub fn get_pixel(&self, x: u32, y: u32) -> Result<Rgba>
pub fn get_pixel(&self, x: u32, y: u32) -> Result<Rgba>
Gets the Rgba pixel at the provided coordinates.
Corresponds to NcVisual::at_yx.
Sourcepub fn set_pixel(&mut self, x: u32, y: u32, rgba: impl Into<Rgba>) -> Result<()>
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.
Sourcepub fn set_degrade(&mut self, degrade: bool)
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).
Sourcepub fn set_transparency(&mut self, color: Option<Rgba>)
pub fn set_transparency(&mut self, color: Option<Rgba>)
(Un)Sets this color as transparent.
Default: None.
Sourcepub fn set_blend(&mut self, blend: bool)
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).
Sourcepub fn set_interpolate(&mut self, interpolate: bool)
pub fn set_interpolate(&mut self, interpolate: bool)
(Un)Sets scaling interpolation.
Default: true (interpolate).
Sourcepub fn set_region(&mut self, x: u32, y: u32, len_x: u32, len_y: u32)
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.
Sourcepub fn set_cell_offset(&mut self, x: u32, y: u32)
pub fn set_cell_offset(&mut self, x: u32, y: u32)
Sets the pixel offset within the Cell.