Commit 818051de authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdiplus: Change atan2 to gdiplus_arctan2.

parent a84b567c
......@@ -154,7 +154,7 @@ static void unstretch_angle(REAL * angle, REAL rad_x, REAL rad_y)
if(cos(*angle) == 0 || sin(*angle) == 0)
return;
stretched = atan2(sin(*angle) / rad_y, cos(*angle) / rad_x);
stretched = gdiplus_atan2(sin(*angle) / rad_y, cos(*angle) / rad_x);
revs_off = roundr(*angle / (2.0 * M_PI)) - roundr(stretched / (2.0 * M_PI));
stretched += ((REAL)revs_off) * M_PI * 2.0;
*angle = stretched;
......@@ -212,3 +212,12 @@ COLORREF ARGB2COLORREF(ARGB color)
(color & 0x00ff00) +
((color & 0xff0000) >> 16);
}
/* Like atan2, but puts angle in correct quadrant if dx is 0. */
FLOAT gdiplus_atan2(FLOAT dy, FLOAT dx)
{
if((dx == 0.0) && (dy != 0.0))
return dy > 0.0 ? M_PI_2 : -M_PI_2;
return atan2(dy, dx);
}
......@@ -30,6 +30,7 @@
COLORREF ARGB2COLORREF(ARGB color);
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
REAL startAngle, REAL sweepAngle);
extern FLOAT gdiplus_atan2(FLOAT dy, FLOAT dx);
static inline INT roundr(REAL x)
{
......
......@@ -146,14 +146,11 @@ static void draw_cap(HDC hdc, COLORREF color, GpLineCap cap, REAL size,
INT i, count;
LOGBRUSH lb;
if(x2 != x1)
theta = atan2(y2 - y1, x2 - x1);
else if(y2 != y1){
theta = M_PI_2 * (y2 > y1 ? 1.0 : -1.0);
}
else
if((x1 == x2) && (y1 == y2))
return;
theta = gdiplus_atan2(y2 - y1, x2 - x1);
brush = CreateSolidBrush(color);
lb.lbStyle = BS_SOLID;
lb.lbColor = color;
......@@ -327,7 +324,7 @@ static void shorten_line_percent(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL per
return;
dist = sqrt((*x2 - x1) * (*x2 - x1) + (*y2 - y1) * (*y2 - y1)) * -percent;
theta = (*x2 == x1 ? M_PI_2 : atan2((*y2 - y1), (*x2 - x1)));
theta = gdiplus_atan2((*y2 - y1), (*x2 - x1));
dx = cos(theta) * dist;
dy = sin(theta) * dist;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment