From 53af28a2088bfcf2b88559fc04d4cc804f894b7c Mon Sep 17 00:00:00 2001 From: rylek Date: Thu, 30 Jul 2009 19:54:41 +0000 Subject: [PATCH] Added implementation for Painter::DrawArc. git-svn-id: svn://ultimatepp.org/upp/trunk@1456 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Painter/DrawOp.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/uppsrc/Painter/DrawOp.cpp b/uppsrc/Painter/DrawOp.cpp index 67617a036..54cd055d4 100644 --- a/uppsrc/Painter/DrawOp.cpp +++ b/uppsrc/Painter/DrawOp.cpp @@ -128,6 +128,18 @@ void Painter::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, void Painter::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color) { + if(rc.Width() <= 0 || rc.Height() <= 0) + return; + Sizef radius = Sizef(rc.Size()) / 2.0; + Pointf center = Pointf(rc.TopLeft()) + radius; + double ang1 = Bearing((Pointf(start) - center) / radius); + double ang2 = Bearing((Pointf(end) - center) / radius); + double sweep = ang1 - ang2; + if(sweep <= 0) + sweep += 2 * M_PI; + Move(center.x + radius.cx * cos(ang1), center.y + radius.cy * sin(ang1)); + Arc(center, radius.cx, radius.cy, ang1, -sweep); + Stroke(max(width, 0), color); } void Painter::DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor)