Grid

Trait Grid 

Source
pub trait Grid {
    // Required methods
    fn size(&self) -> Size;
    fn draw(&mut self, px: &Pixel);
    fn fetch(&self, p: Coordinate) -> Option<Pixel>;
}
Expand description

The Grid which can be implemented by your Project to attach the Pixelflut interface to it.

Required Methods§

Source

fn size(&self) -> Size

Returns the Size of this Grid.

The size of the Grid is defined so that the following can actually be drawn on the grid:

assert_eq!(grid.size(), Size::new(1024, 768));
let pixel: Pixel = "PX 1023 767 ff0f00".parse()?;
grid.draw(pixel);

The following is not working because it is out of bounds:

assert_eq!(grid.size(), Size::new(1024, 768));
let pixel: Pixel = "PX 1024 768 ff0f00".parse()?;
grid.draw(pixel);
Source

fn draw(&mut self, px: &Pixel)

Draw the given Pixel on the Grid.

Source

fn fetch(&self, p: Coordinate) -> Option<Pixel>

Fetch the current status of the Pixel for the given Coordinates. Returns None if no such Pixel exists.

Implementors§