ultimatepp/uppsrc/GLDraw/Arc.cpp
cxl 72405484a0 GLDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@12426 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2018-10-29 10:35:44 +00:00

23 lines
No EOL
614 B
C++

#include "GLDraw.h"
namespace Upp {
void GLArc(Vector<Vector<Pointf>>& line, const Rectf& rc, Pointf start, Pointf end)
{
if(rc.Width() <= 0 || rc.Height() <= 0)
return;
Sizef radius = Sizef(rc.Size()) / 2.0;
Pointf center = Pointf(rc.TopLeft()) + radius;
double ang2 = Direction((Pointf(start) - center) / radius);
double ang1 = Direction((Pointf(end) - center) / radius);
if(ang1 > ang2)
ang2 += M_2PI;
if(ang1 == ang2)
ang2 += M_2PI;
line.Add();
for(double a = ang1; a <= ang2 + M_PI / 200; a += M_PI / 200)
line.Top().Add(radius * Polar(min(a, ang2)) + center);
}
};