mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
[rust] new example issue-1699; issue #1700
- add raqote 2D graphics library as a dev-dependency
This commit is contained in:
parent
217ab0cd90
commit
7e51f04111
@ -39,6 +39,7 @@ serial_test = "^0.5.0"
|
|||||||
serial_test_derive = "^0.5.0"
|
serial_test_derive = "^0.5.0"
|
||||||
|
|
||||||
rand = "^0.8"
|
rand = "^0.8"
|
||||||
|
raqote = "0.8.0"
|
||||||
|
|
||||||
# https://doc.rust-lang.org/cargo/reference/profiles.html
|
# https://doc.rust-lang.org/cargo/reference/profiles.html
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
33
rust/examples/issue-1699.rs
Normal file
33
rust/examples/issue-1699.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// https://github.com/dankamongmen/notcurses/issues/1699
|
||||||
|
// https://github.com/dankamongmen/notcurses/issues/1700
|
||||||
|
|
||||||
|
use libnotcurses_sys::*;
|
||||||
|
use raqote::*;
|
||||||
|
|
||||||
|
const W: u32 = 16;
|
||||||
|
const H: u32 = 8;
|
||||||
|
|
||||||
|
fn main() -> NcResult<()> {
|
||||||
|
let nc = Notcurses::without_altscreen()?;
|
||||||
|
|
||||||
|
println!("pixel support: {:?}", nc.check_pixel_support());
|
||||||
|
|
||||||
|
// use raqote to create a purple rectangle, 16 width, 8 height
|
||||||
|
let mut dt = DrawTarget::new(W as i32, H as i32);
|
||||||
|
dt.clear(SolidSource::from_unpremultiplied_argb(255, 80, 20, 190));
|
||||||
|
// dt.write_png("example.png"); // to check the image is OK
|
||||||
|
|
||||||
|
let vframe1 = NcVisual::from_bgra(dt.get_data_u8(), H, W * 4, W)?;
|
||||||
|
|
||||||
|
// BUG: draws vertical stripes
|
||||||
|
let voptions = NcVisualOptions::without_plane(0, 0, 0, 0, H, W, NCBLIT_1x1, 0, 0);
|
||||||
|
// BUG: nothing gets drawn
|
||||||
|
// let voptions = NcVisualOptions::without_plane(0, 0, 0, 0, H, W, NCBLIT_PIXEL, 0, 0);
|
||||||
|
|
||||||
|
vframe1.render(nc, &voptions)?;
|
||||||
|
|
||||||
|
nc.render()?;
|
||||||
|
vframe1.destroy();
|
||||||
|
nc.stop()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user