From c7f1c32f7fe3c1d9812e337a250e803435149e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Sun, 18 Apr 2021 13:56:36 +0200 Subject: [PATCH] [rust] update pixel-cell example; #1546 --- rust/examples/pixel-cell.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/rust/examples/pixel-cell.rs b/rust/examples/pixel-cell.rs index 062eafdbf..f0e57de30 100644 --- a/rust/examples/pixel-cell.rs +++ b/rust/examples/pixel-cell.rs @@ -24,6 +24,7 @@ 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:"); // fill the buffer with random color pixels let mut rng = rand::thread_rng(); @@ -38,14 +39,14 @@ fn main() -> NcResult<()> { } // show the newly created ncvisual delimited with the box drawing characters - let mut pixels = NcVisual::from_rgba(buffer.as_slice(), pg.cell_y, pg.cell_x * 4, pg.cell_x)?; + let vframe1 = 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); - pixels.render(&mut nc, &voptions)?; + vframe1.render(&mut nc, &voptions)?; rsleep![&mut nc, 1]; // show the ncvisual, scaled - let mut vplane2 = NcPlane::new_bound(&mut stdplane, 4, 4, 4, 4)?; + let mut vplane2 = NcPlane::new_bound(&mut stdplane, 6, 2, 4, 4)?; let voptions2 = NcVisualOptions::with_plane( &mut vplane2, NCSCALE_SCALE, @@ -59,26 +60,26 @@ fn main() -> NcResult<()> { 0, 0, ); - pixels.render(&mut nc, &voptions2)?; + vframe1.render(&mut nc, &voptions2)?; rsleep![&mut nc, 1]; // show the ncvisual, inflated - let voptions3 = NcVisualOptions::without_plane( - 4, - 10, - 0, - 0, - pg.cell_y, - pg.cell_x, - NCBLIT_PIXEL, - 0, - 0, - ); - pixels.inflate(2)?; // FIXME doesn't work (try different values) - pixels.render(&mut nc, &voptions3)?; + 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)?; + 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]; - pixels.destroy(); + vframe1.destroy(); + vframe4.destroy(); Ok(()) }