From fdb30c8ae222354ea2f65a03bd2a602d92fe20ea Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 13 Aug 2017 08:43:31 +0000 Subject: Fix [2874226]: polygon doesn't honor -joinstyle on Windows and OS X. This first fix deals with the OS X case only. --- macosx/tkMacOSXDraw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5ca8bfe..d1e67dc 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -858,6 +858,16 @@ XDrawLines( CGContextAddLineToPoint(dc.context, prevx, prevy); } } + /* + * In the case of closed polylines, the first and last points + * are the same. We want miter or bevel join be rendered also + * at this point, this needs telling CoreGraphics that the + * path is closed. + */ + if ((points[0].x == points[npoints-1].x) && + (points[0].y == points[npoints-1].y)) { + CGContextClosePath(dc.context); + } CGContextStrokePath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); -- cgit v0.12 From 529cbbedfc05feddbb139047b0acca13cf18d516 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 16 Aug 2017 21:57:54 +0000 Subject: Fix [2874226]: polygon doesn't honor -joinstyle on Windows and OS X. This second fix deals with the Windows case only, when drawing non-stippled lines. --- win/tkWinDraw.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 1d17cc6..85d39c5 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -763,7 +763,8 @@ RenderObject( int npoints, int mode, HPEN pen, - WinDrawFunc func) + WinDrawFunc func) /* Name of the Windows GDI drawing function: + this is either Polyline or Polygon. */ { RECT rect = {0,0,0,0}; HPEN oldPen; @@ -861,7 +862,24 @@ RenderObject( SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); + BeginPath(dc); func(dc, winPoints, npoints); + /* + * In the case of closed polylines, the first and last points + * are the same. We want miter or bevel join be rendered also + * at this point, this needs telling the Windows GDI that the + * path is closed. + */ + if ((points[0].x == points[npoints-1].x) && + (points[0].y == points[npoints-1].y)) { + CloseFigure(dc); + } + EndPath(dc); + if (func == Polygon) { + StrokeAndFillPath(dc); + } else { + StrokePath(dc); + } SelectObject(dc, oldPen); } DeleteObject(SelectObject(dc, oldBrush)); -- cgit v0.12 From 0f3176d9ab642b4c8fded958b542546aa7ffb0d0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 17 Aug 2017 21:03:51 +0000 Subject: Rendering of all join styles is now correct on Windows when the first and last point of a polygon or polyline are the same, for both stippled and non stippled lines (and polygon outlines) --- win/tkWinDraw.c | 72 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 85d39c5..e13a5e5 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -741,6 +741,52 @@ XFillRectangles( /* *---------------------------------------------------------------------- * + * MakeAndStrokePath -- + * + * This function draws a shape using a list of points, a stipple pattern, + * and the specified drawing function. It does it through creation of a + * so-called 'path' (see GDI documentation on MSDN). + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static void +MakeAndStrokePath( + HDC dc, + POINT *winPoints, + int npoints, + WinDrawFunc func) /* Name of the Windows GDI drawing function: + this is either Polyline or Polygon. */ +{ + BeginPath(dc); + func(dc, winPoints, npoints); + /* + * In the case of closed polylines, the first and last points + * are the same. We want miter or bevel join be rendered also + * at this point, this needs telling the Windows GDI that the + * path is closed. + */ + if (func == Polyline) { + if ((winPoints[0].x == winPoints[npoints-1].x) && + (winPoints[0].y == winPoints[npoints-1].y)) { + CloseFigure(dc); + } + EndPath(dc); + StrokePath(dc); + } else { + EndPath(dc); + StrokeAndFillPath(dc); + } +} + +/* + *---------------------------------------------------------------------- + * * RenderObject -- * * This function draws a shape using a list of points, a stipple pattern, @@ -763,8 +809,7 @@ RenderObject( int npoints, int mode, HPEN pen, - WinDrawFunc func) /* Name of the Windows GDI drawing function: - this is either Polyline or Polygon. */ + WinDrawFunc func) { RECT rect = {0,0,0,0}; HPEN oldPen; @@ -834,7 +879,7 @@ RenderObject( SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground)); - func(dcMem, winPoints, npoints); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG); /* @@ -846,7 +891,7 @@ RenderObject( if (gc->fill_style == FillOpaqueStippled) { DeleteObject(SelectObject(dcMem, CreateSolidBrush(gc->background))); - func(dcMem, winPoints, npoints); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYBG); } @@ -862,24 +907,7 @@ RenderObject( SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); - BeginPath(dc); - func(dc, winPoints, npoints); - /* - * In the case of closed polylines, the first and last points - * are the same. We want miter or bevel join be rendered also - * at this point, this needs telling the Windows GDI that the - * path is closed. - */ - if ((points[0].x == points[npoints-1].x) && - (points[0].y == points[npoints-1].y)) { - CloseFigure(dc); - } - EndPath(dc); - if (func == Polygon) { - StrokeAndFillPath(dc); - } else { - StrokePath(dc); - } + MakeAndStrokePath(dc, winPoints, npoints, func); SelectObject(dc, oldPen); } DeleteObject(SelectObject(dc, oldBrush)); -- cgit v0.12