pub struct Surface { /* private fields */ }Implementations§
Source§impl Surface
impl Surface
Sourcepub fn put_pixel(&mut self, x: usize, y: usize, color: Color)
pub fn put_pixel(&mut self, x: usize, y: usize, color: Color)
Puts a pixel on the surface
This function is supposed to be called from the draw
callback as passed to the begin_draw function.
Coordinate system: Origin (0, 0) is at top left, with (X, Y) axis going left-to-right, top-to-bottom.
§Arguments
x- X-coordinatey- Y-coordinatecolor- Color of the pixel
Sourcepub fn begin_draw<F>(&mut self, draw_frame: F)where
F: FnMut(&mut Self),
pub fn begin_draw<F>(&mut self, draw_frame: F)where
F: FnMut(&mut Self),
Begins drawing on the surface.
§Arguments
draw_frame- This function is called to draw a single frame at a time. The callback is called at a fixed rate of 60 fps.
§Examples
use fbdraw::{Color, Surface};
let mut surface = Surface::new(1920, 1200);
surface.begin_draw(my_draw_frame);
// Draw a frame on the surface. This function is
// called at a fixed rate of 60 fps.
fn my_draw_frame(surface: &mut Surface) {
let (width, height) = surface.size();
surface.put_pixel(width / 2, height / 2, Color::rgb(255, 0, 0));
}Auto Trait Implementations§
impl Freeze for Surface
impl RefUnwindSafe for Surface
impl Send for Surface
impl Sync for Surface
impl Unpin for Surface
impl UnwindSafe for Surface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.