@ -5,7 +5,7 @@
//! It works on the following terminals:
//! - kitty
//! - xterm (invoked with `xterm -ti vt340`)
//! - alacritty (WIP https://github.com/ayosec/alacritty/tree/graphics)
//! - alacritty (WIP : https://github.com/ayosec/alacritty/tree/graphics)
use rand ::{ distributions ::Uniform , Rng } ;
@ -24,7 +24,8 @@ fn main() -> NcResult<()> {
// print visual delimiters around our pixelized cell
println! ( "0▗│▖\n│─ ─\n2▝│▘" ) ;
println! ( "a cell is {}x{} pixels" , pg . cell_y , pg . cell_x ) ;
println! ( "\nscaled: inflated:" ) ;
println! ( "\ninterpolated not-interpolated" ) ;
println! ( " SCALE SCALE INFLATE RESIZE" ) ;
// fill the buffer with random color pixels
let mut rng = rand ::thread_rng ( ) ;
@ -39,14 +40,14 @@ fn main() -> NcResult<()> {
}
// show the newly created ncvisual delimited with the box drawing characters
let v frame 1 = NcVisual ::from_rgba ( buffer . as_slice ( ) , pg . cell_y , pg . cell_x * 4 , pg . cell_x ) ? ;
let v 1 = NcVisual ::from_rgba ( buffer . as_slice ( ) , pg . cell_y , pg . cell_x * 4 , pg . cell_x ) ? ;
let voptions =
NcVisualOptions ::without_plane ( 1 , 2 , 0 , 0 , pg . cell_y , pg . cell_x , NCBLIT_PIXEL , 0 , 0 ) ;
v frame 1. render ( & mut nc , & voptions ) ? ;
v 1. render ( & mut nc , & voptions ) ? ;
rsleep ! [ & mut nc , 1 ] ;
// show the ncvisual, scaled
let mut vplane2 = NcPlane ::new_bound ( & mut stdplane , 6, 2 , 5 , 4 ) ? ;
// show the ncvisual, scaled with interpolated values
let mut vplane2 = NcPlane ::new_bound ( & mut stdplane , 7, 4 , 5 , 4 ) ? ;
let voptions2 = NcVisualOptions ::with_plane (
& mut vplane2 ,
NCSCALE_SCALE ,
@ -60,27 +61,65 @@ fn main() -> NcResult<()> {
0 ,
0 ,
) ;
v frame 1. render ( & mut nc , & voptions2 ) ? ;
v 1. render ( & mut nc , & voptions2 ) ? ;
rsleep ! [ & mut nc , 1 ] ;
// show the ncvisual, inflated
let voptions3 =
NcVisualOptions ::without_plane ( 6 , 9 , 0 , 0 , pg . cell_y , pg . cell_x , NCBLIT_PIXEL , 0 , 0 ) ;
vframe1 . inflate ( 4 ) ? ;
vframe1 . render ( & mut nc , & voptions3 ) ? ;
// show the ncvisual, scaled without using interpolation
let mut vplane3 = NcPlane ::new_bound ( & mut stdplane , 7 , 19 , 5 , 4 ) ? ;
let voptions3 = NcVisualOptions ::with_plane (
& mut vplane3 ,
NCSCALE_SCALE ,
0 ,
0 ,
0 ,
0 ,
pg . cell_y ,
pg . cell_x ,
NCBLIT_PIXEL ,
NCVISUAL_OPTION_NOINTERPOLATE ,
0 ,
) ;
v1 . render ( & mut nc , & voptions3 ) ? ;
rsleep ! [ & mut nc , 1 ] ;
// inflate the ncvisual (doesn't use interpolation)
let voptions4 =
NcVisualOptions ::without_plane ( 7 , 33 , 0 , 0 , pg . cell_y , pg . cell_x , NCBLIT_PIXEL , 0 , 0 ) ;
v1 . inflate ( 4 ) ? ;
v1 . render ( & mut nc , & voptions4 ) ? ;
rsleep ! [ & mut nc , 1 ] ;
// resize the ncvisual (uses interpolation)
let v5 = NcVisual ::from_rgba ( buffer . as_slice ( ) , pg . cell_y , pg . cell_x * 4 , pg . cell_x ) ? ;
let voptions5 =
NcVisualOptions ::without_plane ( 7 , 45 , 0 , 0 , pg . cell_y , pg . cell_x , NCBLIT_PIXEL , 0 , 0 ) ;
v5 . resize ( 18 * 4 , 9 * 4 ) ? ; // FIXME: render function fails when downsizing (y<18 | x<9)
v5 . render ( & mut nc , & voptions5 ) ? ;
rsleep ! [ & mut nc , 1 ] ;
let vframe4 = NcVisual ::from_rgba ( buffer . as_slice ( ) , pg . cell_y , pg . cell_x * 4 , pg . cell_x ) ? ;
let _voptions4 =
NcVisualOptions ::without_plane ( 6 , 14 , 0 , 0 , pg . cell_y , pg . cell_x , NCBLIT_PIXEL , 0 , 0 ) ;
vframe4 . resize ( 2 , 2 ) ? ;
// FIXME: render function fails
// vframe4.render(&mut nc, &_voptions4)?;
rsleep ! [ & mut nc , 2 ] ;
// resize without interpolation
// WIP: should this substitute the inflate method?
// let v6 = NcVisual::from_rgba(buffer.as_slice(), pg.cell_y, pg.cell_x * 4, pg.cell_x)?;
// let voptions6 = NcVisualOptions::without_plane(
// 7,
// 54,
// 0,
// 0,
// pg.cell_y,
// pg.cell_x,
// NCBLIT_PIXEL,
// NCVISUAL_OPTION_NOINTERPOLATE,
// 0,
// );
// v6.resize(18 * 4, 9 * 4)?;
// v6.render(&mut nc, &voptions6)?;
// rsleep![&mut nc, 1];
vframe1 . destroy ( ) ;
vframe4 . destroy ( ) ;
sleep ! [ 3 ] ;
v1 . destroy ( ) ;
v5 . destroy ( ) ;
// v6.destroy();
nc . stop ( ) ? ;
Ok ( ( ) )
}