pub struct VisualBuilder { /* private fields */ }
Expand description

A Visual builder.

Implementations§

source§

impl VisualBuilder

source

pub fn new() -> Self

Returns a new default VisualBuilder.

Size, position and margins are set to 0. The plane will be maximized to its parent size.

source

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

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

source

pub fn build_from_rgb( self, 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 build_from_rgbx( self, 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 build_from_bgra(self, 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 build_from_file(self, 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 build_from_plane( self, 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 build_from_sixel( self, sequence: &str, len_x: u32, len_y: u32 ) -> Result<Visual>

Builds a new Visual from a nul-terminated Sixel control sequence.

source

pub fn build_from_palidx( self, data: &[u8], x: u32, y: u32, stride: u32, palsize: u8, pstride: u32, palette: Palette ) -> Result<Visual>

Builds a new Visual from pstride-byte palette-indexed pixels, arranged in y lines of stride bytes each, composed of x pixels.

source§

impl VisualBuilder

source

pub fn x(self, x: i32) -> Self

Sets the horizontal placement. Default: 0.

source

pub fn y(self, y: i32) -> Self

Sets the vertical placement. Default: 0.

source

pub fn xy(self, x: i32, y: i32) -> Self

Sets the vertical & horizontal placement. Default: (0, 0).

source

pub fn position(self, position: Position) -> Self

Convenience wrapper around yx.

source

pub fn halign(self, horizontal: Align) -> Self

Sets the horizontal alignment. Default: Align::Left.

source

pub fn valign(self, vertical: Align) -> Self

Sets the vertical alignment. Default: Align::Top.

source

pub fn align(self, horizontal: Align, vertical: Align) -> Self

Sets both the horizontal & vertical alignment. Default: (Align::Top, Align::Left).

source

pub fn scale(self, scale: Scale) -> Self

Sets the Scale. Default: Scale::None.

source

pub fn blitter(self, blitter: Blitter) -> Self

Sets the Blitter. Default: Blitter::Default.

source

pub fn blitter_pixel(self) -> Self

Sets the Pixel blitter.

source

pub fn degrade(self, degrade: bool) -> Self

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

Default: true (degrade).

source

pub fn transparency(self, color: Option<Rgba>) -> Self

(Un)Sets some color as transparent. Default: None.

source

pub fn blend(self, blend: bool) -> Self

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 interpolate(self, interpolate: bool) -> Self

Sets whether the scaling should be done with interpolation or not. Default: true (interpolate).

source

pub fn region(self, x: u32, y: u32, len_x: u32, len_y: u32) -> Self

Sets the region to be rendered.

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

pub fn cell_offset(self, x: u32, y: u32) -> Self

Sets the pixel offset within the Cell.

Trait Implementations§

source§

impl Debug for VisualBuilder

source§

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

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

impl Default for VisualBuilder

source§

fn default() -> VisualBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.