I am trying to draw some black rectangles on a white canvas with ggez
. I've looked at the Generative Art example that's linked at in the ggez
docs.
My problem is, I'm not getting the rectangles to show up, all I get is a white canvas. I've debugged this to see if it correctly enters the draw branch and it does, so I guess there must be an issue with how I use ggez
.
fn draw(&mut self, ctx: &mut ggez::Context) -> GameResult {
let mut canvas = graphics::Canvas::from_frame(ctx, Color::WHITE);
for i in 0..GRID_SIZE.0 {
for j in 0..GRID_SIZE.1 {
if self.grid[i][j] {
let rect = Mesh::new_rectangle(
ctx,
DrawMode::fill(),
Rect::new(
i as f32 * CELL_SIZE.0,
j as f32 * CELL_SIZE.1,
CELL_SIZE.0,
CELL_SIZE.1,
),
Color::BLACK,
)?;
canvas.draw(&rect, DrawParam::default());
}
}
}
canvas.finish(ctx)?;
Ok(())
}