ggez: the trait `ggez::graphics::Drawable` is not implemented for `Result`

Describe the bug I am trying to draw graphics with a mesh containing draw_polygon but the title error is displayed.

To Reproduce See code

Expected behavior Multiple voronoi polygons in a rectangle.

Screenshots or pasted code culprit code:

impl ggez::event::EventHandler<GameError> for State {
    fn update(&mut self, _ctx: &mut ggez::Context) -> GameResult {
        Ok(())
    }
    fn draw(&mut self, ctx: &mut ggez::Context) -> GameResult {
        ggez::graphics::clear(ctx, ggez::graphics::Color::BLACK);
        for shape in &self.shapes {
            // Make the shape...
            let mesh = match shape {
                &Shape::Rectangle(rect) => {
                    ggez::graphics::Mesh::new_rectangle(ctx, ggez::graphics::DrawMode::fill(), rect, ggez::graphics::Color::WHITE)?
                }
                &Shape::Circle(origin, radius) => {
                    ggez::graphics::Mesh::new_circle(ctx, ggez::graphics::DrawMode::fill(), origin, radius, 0.1, ggez::graphics::Color::BLACK)?
                }
            };
            // ...and then draw it.
            ggez::graphics::draw(ctx, &mesh, ggez::graphics::DrawParam::default())?;
        }
        for (i, poly) in self.vor_polys.iter().enumerate() {
            let mut mint = Vec::new();
            for p in poly {
                mint.push(
                    mint::Point2{
                    x: p.x.into_inner() as f32,
                    y: p.y.into_inner() as f32,
                    }
                );
            }
            mint.sort_unstable_by(|a, b| sort_clockwise(Point2::new(a.x as i32, a.y as i32), Point2::new(b.x as i32, b.y as i32),  Point2::new(1920/2, 1080/2)));
            let poly_mesh = ggez::graphics::Mesh::new_polygon(ctx, ggez::graphics::DrawMode::fill() , &mint, ggez::graphics::Color::BLUE);
            ggez::graphics::draw(ctx, &poly_mesh, ggez::graphics::DrawParam::default())?;
        }
        ggez::graphics::present(ctx)?;
        Ok(())
    }

}

Hardware and Software:

  • ggez version: For example, release 0.7.0, latest release
  • OS: Windows 11
  • Graphics card: RTX 3080 laptop
  • Graphics card drivers: 512.15

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (13 by maintainers)

Most upvoted comments

Hey, to let you help me a bit I took the voronoi example from this link . I think I made a mistake by just drawing lines I could try to draw polygons instead; what do you think? I dont want to cover the whole voronoi diagram just a rectangle inside but I am still doing it wrong yes you are right. Will change that.
EDIT: I also made a repo to the code