mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
update doc for ncvisual_resize; fix #1559
This commit is contained in:
parent
d5b58d9f58
commit
0ec15fa920
@ -2734,7 +2734,11 @@ API int ncvisual_rotate(struct ncvisual* n, double rads)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
// Scale the visual to 'rows' X 'columns' pixels, using the best scheme
|
||||
// available. This is a lossy transformation, unless the size is unchanged.
|
||||
// available.
|
||||
//
|
||||
// This is a lossy transformation, unless the size is unchanged.
|
||||
//
|
||||
// Returns -1 if the number of rows or columns is less than the current ones.
|
||||
API int ncvisual_resize(struct ncvisual* n, int rows, int cols)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
|
@ -1,37 +0,0 @@
|
||||
//! https://github.com/dankamongmen/notcurses/issues/1559
|
||||
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
const WIDTH: u32 = 10;
|
||||
const HEIGHT: u32 = 10;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
let mut nc = Nc::new()?;
|
||||
|
||||
if !nc.check_pixel_support()? {
|
||||
return Err(NcError::new_msg("Current terminal doesn't support pixels."));
|
||||
}
|
||||
|
||||
let mut buffer = Vec::<u8>::with_capacity((HEIGHT * WIDTH * 4) as usize);
|
||||
for _byte in (0..={ HEIGHT * WIDTH }) {
|
||||
buffer.push(230);
|
||||
buffer.push(30);
|
||||
buffer.push(40);
|
||||
buffer.push(255);
|
||||
}
|
||||
|
||||
let vframe = NcVisual::from_rgba(buffer.as_slice(), HEIGHT, WIDTH * 4, WIDTH)?;
|
||||
let voptions =
|
||||
NcVisualOptions::without_plane(0, 0, 0, 0, HEIGHT, WIDTH, NCBLIT_PIXEL, 0, 0);
|
||||
|
||||
// vframe.inflate(1)?; // this works
|
||||
|
||||
vframe.resize(1, 1)?; // but it doesn't matter which values we put here
|
||||
|
||||
// FIXME: render always gives an error
|
||||
vframe.render(&mut nc, &voptions)?;
|
||||
|
||||
rsleep![&mut nc, 2];
|
||||
vframe.destroy();
|
||||
Ok(())
|
||||
}
|
@ -339,7 +339,10 @@ impl NcVisual {
|
||||
]
|
||||
}
|
||||
|
||||
/// Resizes the visual so that it is 'rows' X 'columns'.
|
||||
/// Resizes the visual to `rows` X `olumns` pixels.
|
||||
///
|
||||
/// Returns an error if the number of either rows or columns is less than
|
||||
/// the current ones.
|
||||
///
|
||||
/// This is a lossy transformation, unless the size is unchanged.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user