draw arcs with painter path
This commit is contained in:
parent
d5b3fe0dba
commit
11cabf7f27
|
@ -51,29 +51,23 @@ void QskArcRenderer::renderArc( const QRectF& rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
||||||
painter->drawArc( rect, metrics.startAngle(), metrics.spanAngle() );
|
|
||||||
|
|
||||||
if( borderMetrics.width( Qsk::Inner ) > 0 )
|
QPainterPath path( { rect.x() + rect.width() / 2, 0 } ); // 12 o'clock pos
|
||||||
|
path.arcMoveTo( rect, 90 );
|
||||||
|
path.arcTo( rect, metrics.startAngle() + 90, metrics.spanAngle() / 16 );
|
||||||
|
|
||||||
|
painter->drawPath( path );
|
||||||
|
|
||||||
|
if( !borderMetrics.isNull() )
|
||||||
{
|
{
|
||||||
// draw inner border:
|
QPen pen( borderColors.color( Qsk::Outer ), borderMetrics.outerWidth(),
|
||||||
const qreal i = metrics.width() / 2;
|
Qt::SolidLine, Qt::FlatCap );
|
||||||
const auto innerRect = rect.marginsRemoved( { i, i, i, i } );
|
QPainterPathStroker stroker( pen );
|
||||||
const QColor innerColor = borderColors.color( Qsk::Inner );
|
const qreal strokerWidth = metrics.width() - borderMetrics.outerWidth();
|
||||||
|
stroker.setWidth( strokerWidth );
|
||||||
|
QPainterPath strokePath = stroker.createStroke( path );
|
||||||
|
|
||||||
painter->setPen( QPen( innerColor, borderMetrics.width( Qsk::Inner ),
|
painter->setPen( pen );
|
||||||
Qt::SolidLine, Qt::FlatCap ) );
|
painter->drawPath( strokePath );
|
||||||
painter->drawArc( innerRect, metrics.startAngle(), metrics.spanAngle() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( borderMetrics.width( Qsk::Outer ) > 0 )
|
|
||||||
{
|
|
||||||
// draw outer border:
|
|
||||||
const qreal o = ( metrics.width() - borderMetrics.width( Qsk::Outer ) ) / 2;
|
|
||||||
const auto outerRect = rect.marginsAdded( { o, o, o, o } );
|
|
||||||
const QColor outerColor = borderColors.color( Qsk::Outer );
|
|
||||||
|
|
||||||
painter->setPen( QPen( outerColor, borderMetrics.width( Qsk::Outer ),
|
|
||||||
Qt::SolidLine, Qt::FlatCap ) );
|
|
||||||
painter->drawArc( outerRect, metrics.startAngle(), metrics.spanAngle() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue