Struct libnotcurses_sys::examples::Canvas
source · [−]Expand description
A rectangular array of pixels that can be individually colored.
Fields
h: u32The height.
w: u32The width.
buf: Vec<u8>A bytes buffer.
Implementations
sourceimpl Canvas
impl Canvas
sourcepub fn new_colored(h: u32, w: u32, color: NcRgb) -> Self
pub fn new_colored(h: u32, w: u32, color: NcRgb) -> Self
New custom colored Canvas.
sourcepub fn size_cartesian(&self) -> (f32, f32, f32, f32)
pub fn size_cartesian(&self) -> (f32, f32, f32, f32)
Returns the canvas size in cartesian coordinates.
Returns
Cartesian coordinates, goes from the bottom-left to the top-right corner.
(beg_y, end_y, beg_x, end_x)
↓ beg_x (-) 0. (+) end_x ↓
↓
·---------------------------· ← end_y (+)
| |
| |
| |
| + | ← 0.
| |
| |
| |
·---------------------------· ← beg_y (-)sourcepub const fn size_screen(&self) -> (u32, u32, u32, u32)
pub const fn size_screen(&self) -> (u32, u32, u32, u32)
Returns the canvas size in screen coordinates.
Returns
Screen coordinates, goes from the top-left to the bottom-right corner.
(beg_y, end_y, beg_x, end_x)
↓ beg_x (0) end_x ↓
+---------------------------· ← beg_y (0)
| |
| |
| |
| |
| |
| |
| |
·---------------------------· ← end_ysourcepub fn set_pixel(&mut self, y: f32, x: f32, color: NcRgb)
pub fn set_pixel(&mut self, y: f32, x: f32, color: NcRgb)
Assigns a color to a pixel, using cartesian coordinates.
sourcepub fn set_pixel2(&mut self, y: u32, x: u32, color: NcRgb)
pub fn set_pixel2(&mut self, y: u32, x: u32, color: NcRgb)
Assigns a color to a pixel, using screen coordinates.
sourcepub fn s2c(&self, y: u32, x: u32) -> (f32, f32)
pub fn s2c(&self, y: u32, x: u32) -> (f32, f32)
Performs conversion from screen coordinates to cartesian coordiantes.
In screen coordinates the origin (0,0) is at the top left:
yincreases towards the bottom.xincreases towards the right.
pub fn s2c_y(&self, y: u32) -> f32
pub fn s2c_x(&self, x: u32) -> f32
sourcepub fn c2s(&self, y: f32, x: f32) -> (u32, u32)
pub fn c2s(&self, y: f32, x: f32) -> (u32, u32)
Performs conversion from cartesian coordinates to screen coordiantes.
In cartesian coordiantes the origin (0,0) is at the center:
yincreases towards the top and decreases towards the bottom.xincreases towards the right and decreases towards the left.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Canvas
impl Send for Canvas
impl Sync for Canvas
impl Unpin for Canvas
impl UnwindSafe for Canvas
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more