[rust] add example issue #1751

pull/1755/head
joseLuís 3 years ago
parent 5912a2138a
commit 0ea7c5236d

@ -0,0 +1,23 @@
use libnotcurses_sys::*;
const W: u32 = 32;
const H: u32 = 32;
fn main() -> NcResult<()> {
let nc = Notcurses::new()?;
// create a white rectangle
let buffer = vec![255; H as usize * W as usize * 4];
let v = NcVisual::from_rgba(buffer.as_slice(), H, W * 4, W)?;
let vo = NcVisualOptions::without_plane(0, 0, 0, 0, H, W, NCBLIT_PIXEL, 0, 0);
// BUG: render function fails when downsizing
v.resize(H / 2, W / 2)?;
v.render(nc, &vo)?;
rsleep![nc, 1];
v.destroy();
nc.stop()?;
Ok(())
}

@ -348,7 +348,7 @@ impl NcVisual {
) -> NcResult<&mut NcPlane> {
error_ref_mut![
unsafe { crate::ncvisual_render(nc, self, options) },
"NcVisual.render()"
"NcVisual.render(Notcurses, &NcVisualOptions)"
]
}

Loading…
Cancel
Save