gdiplus: Change atan2 to gdiplus_arctan2.
This commit is contained in:
parent
a84b567cba
commit
818051de2c
|
@ -154,7 +154,7 @@ static void unstretch_angle(REAL * angle, REAL rad_x, REAL rad_y)
|
||||||
if(cos(*angle) == 0 || sin(*angle) == 0)
|
if(cos(*angle) == 0 || sin(*angle) == 0)
|
||||||
return;
|
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));
|
revs_off = roundr(*angle / (2.0 * M_PI)) - roundr(stretched / (2.0 * M_PI));
|
||||||
stretched += ((REAL)revs_off) * M_PI * 2.0;
|
stretched += ((REAL)revs_off) * M_PI * 2.0;
|
||||||
*angle = stretched;
|
*angle = stretched;
|
||||||
|
@ -212,3 +212,12 @@ COLORREF ARGB2COLORREF(ARGB color)
|
||||||
(color & 0x00ff00) +
|
(color & 0x00ff00) +
|
||||||
((color & 0xff0000) >> 16);
|
((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);
|
COLORREF ARGB2COLORREF(ARGB color);
|
||||||
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
|
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
|
||||||
REAL startAngle, REAL sweepAngle);
|
REAL startAngle, REAL sweepAngle);
|
||||||
|
extern FLOAT gdiplus_atan2(FLOAT dy, FLOAT dx);
|
||||||
|
|
||||||
static inline INT roundr(REAL x)
|
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;
|
INT i, count;
|
||||||
LOGBRUSH lb;
|
LOGBRUSH lb;
|
||||||
|
|
||||||
if(x2 != x1)
|
if((x1 == x2) && (y1 == y2))
|
||||||
theta = atan2(y2 - y1, x2 - x1);
|
|
||||||
else if(y2 != y1){
|
|
||||||
theta = M_PI_2 * (y2 > y1 ? 1.0 : -1.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
theta = gdiplus_atan2(y2 - y1, x2 - x1);
|
||||||
|
|
||||||
brush = CreateSolidBrush(color);
|
brush = CreateSolidBrush(color);
|
||||||
lb.lbStyle = BS_SOLID;
|
lb.lbStyle = BS_SOLID;
|
||||||
lb.lbColor = color;
|
lb.lbColor = color;
|
||||||
|
@ -327,7 +324,7 @@ static void shorten_line_percent(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL per
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dist = sqrt((*x2 - x1) * (*x2 - x1) + (*y2 - y1) * (*y2 - y1)) * -percent;
|
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;
|
dx = cos(theta) * dist;
|
||||||
dy = sin(theta) * dist;
|
dy = sin(theta) * dist;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue