fixed implementaion mistake

This commit is contained in:
Karma Riuk 2023-03-14 22:00:55 +01:00
parent 9fd87b7f29
commit 37198d4669

View File

@ -9,7 +9,7 @@ void polygons_init_state() {
polygons = new polygon[n_polygons]; polygons = new polygon[n_polygons];
polygon poly = polygon poly =
polygon{{400, 400}, 0, {{0, 0}, {0, 100}, {100, 100}, {100, 0}}}; polygon{{400, 400}, 0, {{-50, -50}, {50, -50}, {50, 50}, {-50, 50}}};
polygons[0] = poly; polygons[0] = poly;
} }
@ -18,10 +18,9 @@ void polygon::draw(cairo_t* cr) const {
vec2d& center = poly.center; vec2d& center = poly.center;
cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_source_rgb(cr, 1, 1, 1);
cairo_move_to(cr, center.x, center.y);
for (auto& point : poly.points) for (auto& point : poly.points)
cairo_line_to(cr, center.x + point.x, center.y + point.y); cairo_line_to(cr, center.x + point.x, center.y + point.y);
cairo_line_to(cr, center.x, center.y); cairo_line_to(cr, center.x + poly.points[0].x, center.y + poly.points[0].y);
cairo_stroke(cr); cairo_stroke(cr);
} }