From f4b0e7e35e4f3dd02508e7e69d6ea60f04489970 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 11 Oct 2015 23:48:40 -0400 Subject: [PATCH] Added negative arcs to the OS X backend. Now we have a crash in one of the tests; still debugging. --- darwin/draw.m | 17 +++++++++++------ test/drawtests.c | 19 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/darwin/draw.m b/darwin/draw.m index 514590f3..6a7f6c25 100644 --- a/darwin/draw.m +++ b/darwin/draw.m @@ -30,7 +30,7 @@ void uiDrawPathNewFigure(uiDrawPath *p, double x, double y) CGPathMoveToPoint(p->path, NULL, x, y); } -void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep) +void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative) { double sinStart, cosStart; double startx, starty; @@ -42,7 +42,7 @@ void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, d startx = xCenter + radius * cosStart; starty = yCenter + radius * sinStart; CGPathMoveToPoint(p->path, NULL, startx, starty); - uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep); + uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep, negative); } void uiDrawPathLineTo(uiDrawPath *p, double x, double y) @@ -52,16 +52,22 @@ void uiDrawPathLineTo(uiDrawPath *p, double x, double y) CGPathAddLineToPoint(p->path, NULL, x, y); } -void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep) +void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative) { + bool cw; + if (p->ended) complain("attempt to add arc to ended path in uiDrawPathArcTo()"); if (sweep > 2 * M_PI) sweep = 2 * M_PI; - CGPathAddRelativeArc(p->path, NULL, + cw = false; + if (negative) + cw = true; + CGPathAddArc(p->path, NULL, xCenter, yCenter, radius, - startAngle, sweep); + startAngle, startAngle + sweep, + cw); } void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY) @@ -137,7 +143,6 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro switch (p->Join) { case uiDrawLineJoinMiter: join = kCGLineJoinMiter; - CGContextSetMiterLimit(c->c, p->MiterLimit); break; case uiDrawLineJoinRound: join = kCGLineJoinRound; diff --git a/test/drawtests.c b/test/drawtests.c index 81b6d455..6d1004b6 100644 --- a/test/drawtests.c +++ b/test/drawtests.c @@ -1160,21 +1160,21 @@ static void drawCSFillStyle(uiAreaDrawParams *p) sp.Thickness = 6; path = uiDrawNewPath(uiDrawFillModeAlternate); - uiDrawPathAddRectangle(path, 12, 12, 232, 70); +// uiDrawPathAddRectangle(path, 12, 12, 232, 70); uiDrawPathNewFigureWithArc(path, 64, 64, 40, 0, 2*M_PI, 0); - uiDrawPathNewFigureWithArc(path, +/* uiDrawPathNewFigureWithArc(path, 192, 64, 40, 0, -2*M_PI, 1); - uiDrawPathEnd(path); +*/ uiDrawPathEnd(path); crsourcergba(&source, 0, 0.7, 0, 1); - uiDrawFill(p->Context, path, &source); +// uiDrawFill(p->Context, path, &source); crsourcergba(&source, 0, 0, 0, 1); uiDrawStroke(p->Context, path, &source, &sp); uiDrawFreePath(path); @@ -1184,9 +1184,8 @@ static void drawCSFillStyle(uiAreaDrawParams *p) uiDrawTransform(p->Context, &m); path = uiDrawNewPath(uiDrawFillModeWinding); - uiDrawPathAddRectangle(path, 12, 12, 232, 70); -// TODO THIS DOESN'T WORK. - uiDrawPathNewFigureWithArc(path, +// uiDrawPathAddRectangle(path, 12, 12, 232, 70); +/* uiDrawPathNewFigureWithArc(path, 64, 64, 40, 0, 2*M_PI, @@ -1196,12 +1195,12 @@ static void drawCSFillStyle(uiAreaDrawParams *p) 40, 0, -2*M_PI, 1); - uiDrawPathEnd(path); +*/ uiDrawPathEnd(path); crsourcergba(&source, 0, 0, 0.9, 1); - uiDrawFill(p->Context, path, &source); +// uiDrawFill(p->Context, path, &source); crsourcergba(&source, 0, 0, 0, 1); - uiDrawStroke(p->Context, path, &source, &sp); +// uiDrawStroke(p->Context, path, &source, &sp); uiDrawFreePath(path); }