C++ (Qt)#define PI 3.141592f struct CArcGen { CArcGen( void ); void CreatePolys( int steps, QVector <QPolygonF> & poly ) const; qreal mBegAngle; // начальный угол в радианах qreal mEndAngle; // конечный угол в радианах QPointF mCenter; // центр QPointF mRadIn, mRadOut; // внешний и внутренний радиусы по x и у}; CArcGen::CArcGen( void ) : mBegAngle(0.0f), mEndAngle(PI / 2), mRadOut(100, 100){} void CArcGen::CreatePolys( int steps, QVector <QPolygonF> & poly ) const{ steps = qMax(steps, 1); qreal delta = (mEndAngle - mBegAngle) / steps; qreal angle = mAngleBeg; qreal cos1 = cos(angle); qreal sin1 = sin(angle); for (int i = 0; i < steps; ++i) { angle += delta; qreal cos2 = cos(angle); qreal sin2 = sin(angle); poly.push_back(QPolygonF()); QPolygonF & dst = poly.back(); dst.push_back(QPointF(mRadOut.x() * cos1, mRadOut.y() * sin1)); dst.push_back(QPointF(mRadOut.x() * cos2, mRadOut.y() * sin2)); dst.push_back(QPointF(mRadIn.x() * cos2, mRadIn.y() * sin2)); dst.push_back(QPointF(mRadIn.x() * cos1, mRadIn.y() * sin1)); dst.translate(mCenter); cos1 = cos2; sin1 = sin2; }}
C++ (Qt)QList<QPolygonF> QPainterPath::toFillPolygons ( const QTransform & matrix ) const