Made 90° point toward y=+∞.

This commit is contained in:
Pietro Gagliardi 2015-10-11 20:24:06 -04:00
parent 9cb2c922b8
commit b09cdb5137
3 changed files with 8 additions and 12 deletions

View File

@ -40,7 +40,7 @@ void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, d
sinStart = sin(startAngle); sinStart = sin(startAngle);
cosStart = cos(startAngle); cosStart = cos(startAngle);
startx = xCenter + radius * cosStart; startx = xCenter + radius * cosStart;
starty = yCenter - radius * sinStart; starty = yCenter + radius * sinStart;
CGPathMoveToPoint(p->path, NULL, startx, starty); CGPathMoveToPoint(p->path, NULL, startx, starty);
uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep); uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep);
} }
@ -61,8 +61,7 @@ void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radiu
CGPathAddRelativeArc(p->path, NULL, CGPathAddRelativeArc(p->path, NULL,
xCenter, yCenter, xCenter, yCenter,
radius, radius,
// TODO explain this startAngle, sweep);
-startAngle, -sweep);
} }
void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY) void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY)

View File

@ -152,15 +152,12 @@ static void runPath(uiDrawPath *p, cairo_t *cr)
cairo_new_sub_path(cr); cairo_new_sub_path(cr);
// fall through // fall through
case arcTo: case arcTo:
// cairo_arc() and cairo_arc_negative() only go clockwise cairo_arc(cr,
// TODO explain why this works
// don't use cairo_arc(); that requires us to put the starting point as the ending point
cairo_arc_negative(cr,
piece->d[0], piece->d[0],
piece->d[1], piece->d[1],
piece->d[2], piece->d[2],
-(piece->d[3]), piece->d[3],
-(piece->d[3] + piece->d[4])); piece->d[3] + piece->d[4]);
break; break;
case lineTo: case lineTo:
cairo_line_to(cr, piece->d[0], piece->d[1]); cairo_line_to(cr, piece->d[0], piece->d[1]);

View File

@ -185,11 +185,11 @@ static void drawArc(uiDrawPath *p, struct arc *a, void (*startFunction)(uiDrawPa
sinx = sin(a->startAngle); sinx = sin(a->startAngle);
cosx = cos(a->startAngle); cosx = cos(a->startAngle);
startX = a->xCenter + a->radius * cosx; startX = a->xCenter + a->radius * cosx;
startY = a->yCenter - a->radius * sinx; startY = a->yCenter + a->radius * sinx;
sinx = sin(a->startAngle + a->sweep); sinx = sin(a->startAngle + a->sweep);
cosx = cos(a->startAngle + a->sweep); cosx = cos(a->startAngle + a->sweep);
endX = a->xCenter + a->radius * cosx; endX = a->xCenter + a->radius * cosx;
endY = a->yCenter - a->radius * sinx; endY = a->yCenter + a->radius * sinx;
// now do the initial step to get the current point to be the start point // now do the initial step to get the current point to be the start point
// this is either creating a new figure, drawing a line, or (in the case of our full circle code above) doing nothing // this is either creating a new figure, drawing a line, or (in the case of our full circle code above) doing nothing
@ -202,7 +202,7 @@ static void drawArc(uiDrawPath *p, struct arc *a, void (*startFunction)(uiDrawPa
as.size.width = a->radius; as.size.width = a->radius;
as.size.height = a->radius; as.size.height = a->radius;
as.rotationAngle = 0; // as above, not relevant for circles as.rotationAngle = 0; // as above, not relevant for circles
as.sweepDirection = D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE; as.sweepDirection = D2D1_SWEEP_DIRECTION_CLOCKWISE;
if (a->sweep > M_PI) if (a->sweep > M_PI)
as.arcSize = D2D1_ARC_SIZE_LARGE; as.arcSize = D2D1_ARC_SIZE_LARGE;
else else