summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gdiplus/cdwinp.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/gdiplus/cdwinp.cpp b/src/gdiplus/cdwinp.cpp
index 2a362d0..f01884f 100644
--- a/src/gdiplus/cdwinp.cpp
+++ b/src/gdiplus/cdwinp.cpp
@@ -624,14 +624,26 @@ static void cdfbox(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin
}
}
-static void sFixAngles(cdCanvas* canvas, double *a1, double *a2)
+static void sFixAngles(cdCanvas* canvas, double *a1, double *a2, double w, double h)
{
+ // the angles relative to the center are dependent from the ellipse size.
+ // in GDI+ must use the actual angle
+ if (*a1!=0 && *a1!=90 && *a1!=180 && *a1!=360 && w!=h)
+ {
+ *a1 = atan2((h/2.0)*sin(*a1*CD_DEG2RAD), (w/2.0)*cos(*a1*CD_DEG2RAD))*CD_RAD2DEG;
+ if (*a1 < 0) *a1 += 360;
+ }
+ if (*a2!=0 && *a2!=90 && *a2!=180 && *a2!=360 && w!=h)
+ {
+ *a2 = atan2((h/2.0)*sin(*a2*CD_DEG2RAD), (w/2.0)*cos(*a2*CD_DEG2RAD))*CD_RAD2DEG;
+ if (*a2 < 0) *a2 += 360;
+ }
+
// GDI+ angles are clock-wise by default, in degrees
/* if NOT inverted means a transformation is set,
so the angle will follow the transformation that includes the axis invertion,
then it is already counter-clockwise */
-
if (canvas->invert_yaxis)
{
/* change orientation */
@@ -649,7 +661,7 @@ static void cdarc(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double a
ctxcanvas->graphics->DrawEllipse(ctxcanvas->linePen, rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
ctxcanvas->graphics->DrawArc(ctxcanvas->linePen, rect, (REAL)angle1, (REAL)(angle2-angle1));
}
ctxcanvas->dirty = 1;
@@ -662,7 +674,7 @@ static void cdfarc(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, doubl
ctxcanvas->graphics->DrawEllipse(ctxcanvas->linePen, rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
ctxcanvas->graphics->DrawArc(ctxcanvas->linePen, rect, (REAL)angle1, (REAL)(angle2-angle1));
}
ctxcanvas->dirty = 1;
@@ -678,7 +690,7 @@ static void cdsector(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, doubl
path.AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddPie(rect, (REAL)angle1, (REAL)(angle2-angle1));
}
Region region(&path);
@@ -696,10 +708,11 @@ static void cdsector(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, doubl
}
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
ctxcanvas->graphics->FillPie(ctxcanvas->fillBrush, rect, (REAL)angle1, (REAL)(angle2-angle1));
ctxcanvas->graphics->DrawArc(&pen, rect, (REAL)angle1, (REAL)(angle2-angle1));
}
+
ctxcanvas->dirty = 1;
}
}
@@ -714,7 +727,7 @@ static void cdfsector(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, do
path.AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddPie(rect, (REAL)angle1, (REAL)(angle2-angle1));
}
Region region(&path);
@@ -732,7 +745,7 @@ static void cdfsector(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, do
}
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
ctxcanvas->graphics->FillPie(ctxcanvas->fillBrush, rect, (REAL)angle1, (REAL)(angle2-angle1));
ctxcanvas->graphics->DrawArc(&pen, rect, (REAL)angle1, (REAL)(angle2-angle1));
}
@@ -750,7 +763,7 @@ static void cdchord(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double
path.AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddArc(rect, (REAL)angle1, (REAL)(angle2-angle1));
path.CloseFigure();
}
@@ -764,7 +777,7 @@ static void cdchord(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double
else
{
GraphicsPath path;
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddArc(rect, (REAL)angle1, (REAL)(angle2-angle1));
ctxcanvas->graphics->FillPath(ctxcanvas->fillBrush, &path);
}
@@ -784,7 +797,7 @@ static void cdfchord(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, dou
path.AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddArc(rect, (REAL)angle1, (REAL)(angle2-angle1));
path.CloseFigure();
}
@@ -798,7 +811,7 @@ static void cdfchord(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, dou
else
{
GraphicsPath path;
- sFixAngles(ctxcanvas->canvas, &angle1, &angle2);
+ sFixAngles(ctxcanvas->canvas, &angle1, &angle2, w, h);
path.AddArc(rect, (REAL)angle1, (REAL)(angle2-angle1));
ctxcanvas->graphics->FillPath(ctxcanvas->fillBrush, &path);
}
@@ -874,7 +887,7 @@ static void cdpoly(cdCtxCanvas* ctxcanvas, int mode, cdPoint* poly, int n)
graphics_path->AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &a1, &a2);
+ sFixAngles(ctxcanvas->canvas, &a1, &a2, w, h);
graphics_path->AddArc(rect, (REAL)a1, (REAL)(a2-a1));
}
@@ -1098,7 +1111,7 @@ static void cdfpoly(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* poly, int n)
graphics_path->AddEllipse(rect);
else
{
- sFixAngles(ctxcanvas->canvas, &a1, &a2);
+ sFixAngles(ctxcanvas->canvas, &a1, &a2, w, h);
graphics_path->AddArc(rect, (REAL)a1, (REAL)(a2-a1));
}