pub struct PixelHandler {
pub pixels: HashMap<GridPosition, Pixel>,
/* private fields */
}Fields§
§pixels: HashMap<GridPosition, Pixel>Implementations§
Source§impl PixelHandler
impl PixelHandler
Sourcepub fn draw_grid(&mut self, ctx: &mut Context, grid_color: Color)
pub fn draw_grid(&mut self, ctx: &mut Context, grid_color: Color)
Examples found in repository?
More examples
examples/pixel_offscreen.rs (line 40)
36 fn draw(&mut self, ctx: &mut Context) -> GameResult {
37 let mut canvas = Canvas::from_frame(ctx, Color::WHITE);
38 let pixel_handler = &mut self.pixel_handler;
39
40 pixel_handler.draw_grid(ctx, Color::BLACK);
41 pixel_handler.display_fps(ctx);
42
43 for (_position, pixel) in pixel_handler.pixels.iter_mut() {
44 let next_position = pixel.position + GridPosition::new(0, 1, CELL_SIZE);
45
46 if next_position.is_offscreen(ctx) {
47 continue;
48 } else {
49 pixel.position = next_position;
50 }
51 }
52
53 pixel_handler.update(&mut canvas, ctx);
54 canvas.finish(ctx)
55 }pub fn get_fps(&self) -> f32
Sourcepub fn display_fps(&mut self, ctx: &mut Context)
pub fn display_fps(&mut self, ctx: &mut Context)
Examples found in repository?
More examples
examples/pixel_offscreen.rs (line 41)
36 fn draw(&mut self, ctx: &mut Context) -> GameResult {
37 let mut canvas = Canvas::from_frame(ctx, Color::WHITE);
38 let pixel_handler = &mut self.pixel_handler;
39
40 pixel_handler.draw_grid(ctx, Color::BLACK);
41 pixel_handler.display_fps(ctx);
42
43 for (_position, pixel) in pixel_handler.pixels.iter_mut() {
44 let next_position = pixel.position + GridPosition::new(0, 1, CELL_SIZE);
45
46 if next_position.is_offscreen(ctx) {
47 continue;
48 } else {
49 pixel.position = next_position;
50 }
51 }
52
53 pixel_handler.update(&mut canvas, ctx);
54 canvas.finish(ctx)
55 }Sourcepub fn register_pixel(&mut self, pixel: Pixel)
pub fn register_pixel(&mut self, pixel: Pixel)
pub fn position_occupied(&self, position: &GridPosition) -> bool
pub fn get_pixel(&self, position: &GridPosition) -> Option<&Pixel>
Sourcepub fn update(&mut self, canvas: &mut Canvas, ctx: &mut Context)
pub fn update(&mut self, canvas: &mut Canvas, ctx: &mut Context)
Examples found in repository?
More examples
examples/pixel_offscreen.rs (line 53)
36 fn draw(&mut self, ctx: &mut Context) -> GameResult {
37 let mut canvas = Canvas::from_frame(ctx, Color::WHITE);
38 let pixel_handler = &mut self.pixel_handler;
39
40 pixel_handler.draw_grid(ctx, Color::BLACK);
41 pixel_handler.display_fps(ctx);
42
43 for (_position, pixel) in pixel_handler.pixels.iter_mut() {
44 let next_position = pixel.position + GridPosition::new(0, 1, CELL_SIZE);
45
46 if next_position.is_offscreen(ctx) {
47 continue;
48 } else {
49 pixel.position = next_position;
50 }
51 }
52
53 pixel_handler.update(&mut canvas, ctx);
54 canvas.finish(ctx)
55 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for PixelHandler
impl !RefUnwindSafe for PixelHandler
impl Send for PixelHandler
impl Sync for PixelHandler
impl Unpin for PixelHandler
impl !UnwindSafe for PixelHandler
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> HasMut<T> for T
impl<T> HasMut<T> for T
Source§fn retrieve_mut(&mut self) -> &mut T
fn retrieve_mut(&mut self) -> &mut T
Method to retrieve the context type as mutable.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more