Struct notcurses::VisualBuilder
source · pub struct VisualBuilder { /* private fields */ }Expand description
A Visual builder.
Implementations§
source§impl VisualBuilder
impl VisualBuilder
sourcepub fn new() -> Self
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.
sourcepub fn build_from_rgba(self, rgba: &[u8], size: impl Into<Size>) -> Result<Visual>
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.
sourcepub fn build_from_rgb(
self,
rgb: &[u8],
size: impl Into<Size>,
alpha: u8
) -> Result<Visual>
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.
sourcepub fn build_from_rgbx(
self,
rgbx: &[u8],
size: impl Into<Size>,
alpha: u8
) -> Result<Visual>
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.
sourcepub fn build_from_bgra(self, bgra: &[u8], size: impl Into<Size>) -> Result<Visual>
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.
sourcepub fn build_from_file(self, file: &str) -> Result<Visual>
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.
sourcepub 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>
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§impl VisualBuilder
impl VisualBuilder
sourcepub fn xy(self, x: i32, y: i32) -> Self
pub fn xy(self, x: i32, y: i32) -> Self
Sets the vertical & horizontal placement. Default: (0, 0).
sourcepub fn halign(self, horizontal: Align) -> Self
pub fn halign(self, horizontal: Align) -> Self
Sets the horizontal alignment. Default: Align::Left.
sourcepub fn valign(self, vertical: Align) -> Self
pub fn valign(self, vertical: Align) -> Self
Sets the vertical alignment. Default: Align::Top.
sourcepub fn align(self, horizontal: Align, vertical: Align) -> Self
pub fn align(self, horizontal: Align, vertical: Align) -> Self
Sets both the horizontal & vertical alignment.
Default: (Align::Top, Align::Left).
sourcepub fn scale(self, scale: Scale) -> Self
pub fn scale(self, scale: Scale) -> Self
Sets the Scale. Default: Scale::None.
sourcepub fn blitter(self, blitter: Blitter) -> Self
pub fn blitter(self, blitter: Blitter) -> Self
Sets the Blitter. Default: Blitter::Default.
sourcepub fn blitter_pixel(self) -> Self
pub fn blitter_pixel(self) -> Self
Sets the Pixel blitter.
sourcepub fn degrade(self, degrade: bool) -> Self
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).
sourcepub fn transparency(self, color: Option<Rgba>) -> Self
pub fn transparency(self, color: Option<Rgba>) -> Self
(Un)Sets some color as transparent. Default: None.
sourcepub fn blend(self, blend: bool) -> Self
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).
sourcepub fn interpolate(self, interpolate: bool) -> Self
pub fn interpolate(self, interpolate: bool) -> Self
Sets whether the scaling should be done with interpolation or not. Default: true (interpolate).
sourcepub fn region(self, x: u32, y: u32, len_x: u32, len_y: u32) -> Self
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.
sourcepub fn cell_offset(self, x: u32, y: u32) -> Self
pub fn cell_offset(self, x: u32, y: u32) -> Self
Sets the pixel offset within the Cell.