mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
b12abeddc9
- change Option return type for NcResult when appropriate. - make NcDirect constructors return NcResult. - rename NcError::new() to with_msg() and simplify new(). - refactor examples: - rename direct-image.rs to direct-image-c.rs - recreate using rust methods, as direct-image-rust.rs - differentiate more throughly between both styles. - remove the sys namespace on both examples.
33 lines
798 B
Rust
33 lines
798 B
Rust
//! Example 'direct-image'
|
|
//!
|
|
//! Explore image rendering in direct mode
|
|
//!
|
|
//! NOTE: This example uses the Rust style with methods.
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
fn main() -> NcResult<()> {
|
|
let ncd = NcDirect::new()?;
|
|
|
|
render_image(ncd, NCBLIT_1x1)?;
|
|
render_image(ncd, NCBLIT_2x1)?;
|
|
render_image(ncd, NCBLIT_BRAILLE)?;
|
|
|
|
ncd.stop()?;
|
|
Ok(())
|
|
}
|
|
|
|
fn render_image(ncd: &mut NcDirect, blit: NcBlitter) -> NcResult<()>{
|
|
if let Err(nc_error) = ncd.render_image(
|
|
"image-16x16.png",
|
|
NCALIGN_CENTER,
|
|
blit,
|
|
NCSCALE_NONE,
|
|
) {
|
|
return Err(NcError::with_msg(nc_error.int,
|
|
"ERROR: ncdirect_render_image(). Make sure you \
|
|
are running this example from the examples folder"));
|
|
}
|
|
Ok(())
|
|
}
|