shithub: puzzles

Download patch

ref: 4deb970743f110dc438bd8e082886a3bacc1e8e1
parent: 819277148315fd5b5cc987e4b4e440e5b2bd2dad
author: sirjofri <sirjofri@sirjofri.de>
date: Fri Jun 7 08:34:05 EDT 2024

fixes polygon drawing

--- a/plan9.c
+++ b/plan9.c
@@ -244,16 +244,17 @@
 	Point *points;
 	frontend *fe = (frontend*)handle;
 	
-	points = malloc(npoints * sizeof(Point));
+	points = malloc((npoints+1) * sizeof(Point));
 	for (int i = 0; i < npoints; i++) {
 		points[i].x = coords[i*2+0] + fe->ZP.x;
 		points[i].y = coords[i*2+1] + fe->ZP.y;
 	}
+	points[npoints] = points[0];
 	
 	if (fillcolor >= 0)
 		fillpoly(screen, points, npoints, 0, fe->colors[fillcolor], ZP);
 	if (outlinecolor >= 0)
-		poly(screen, points, npoints, Endsquare, Endsquare, 0, fe->colors[outlinecolor], ZP);
+		poly(screen, points, npoints+1, Endsquare, Endsquare, 0, fe->colors[outlinecolor], ZP);
 	
 	free(points);
 }