Commits

Anonymous committed fa74e65

line drawing fixups

Comments (0)

Files changed (2)

 # BREAK = change breaks existing code
 # BUG   = fixed a bug that was crashing
 
+May 23, 2001
+	fixed line drawing of width 1
+	draw.lines() was broken with sections outside clip
+
 May 22, 2001
 	added midleft, midright, midtop, and midbottom to Rect
 	added Rect.unionall() function to union a list of Rects
 	Uint32 color;
 	int closed;
 	int result, loop, length, drawn;
+	int startx, starty;
 
 	/*get all the arguments*/
 	if(!PyArg_ParseTuple(arg, "O!OOO|i", &PySurface_Type, &surfobj, &colorobj, &closedobj, &points, &width))
 	Py_DECREF(item);
 	if(!result) return RAISE(PyExc_TypeError, "points must be number pairs");
 
-	pts[0] = left = right = x;
-	pts[1] = top = bottom = y;
+	startx = pts[0] = left = right = x;
+	starty = pts[1] = top = bottom = y;
 
 	if(width < 1)
 		return PyRect_New4((short)left, (short)top, 0, 0);
 		Py_DECREF(item);
 		if(!result) continue; /*note, we silently skip over bad points :[ */
 		++drawn;
-		pts[2] = x;
-		pts[3] = y;
-
+		pts[0] = startx;
+		pts[1] = starty;
+		startx = pts[2] = x;
+		starty = pts[3] = y;
 		if(clip_and_draw_line_width(surf, &surf->clip_rect, color, width, pts))
 		{
 			left = min(min(pts[0], pts[2]), left);
 			right = max(max(pts[0], pts[2]), right);
 			bottom = max(max(pts[1], pts[3]), bottom);
 		}
-
-		pts[0] = pts[2];
-		pts[1] = pts[3];
 	}
 	if(closed && drawn > 2)
 	{
 		Py_DECREF(item);
 		if(result)
 		{
+			pts[0] = startx;
+			pts[1] = starty;
 			pts[2] = x;
 			pts[3] = y;
 			clip_and_draw_line_width(surf, &surf->clip_rect, color, width, pts);
 	int range[4];
 	int anydrawn = 0;
 
-
 	if(abs(pts[0]-pts[2]) > abs(pts[1]-pts[3]))
 		yinc = 1;
 	else
 		range[2] = range[3] = -10000;
 	}
 
-	for(loop = 0; loop < width; loop += 2)
+	for(loop = 1; loop < width; loop += 2)
 	{
 		newpts[0] = pts[0] + xinc*(loop/2+1);
 		newpts[1] = pts[1] + yinc*(loop/2+1);