better painter paths for >= 360°

This commit is contained in:
Uwe Rathmann 2024-01-22 14:10:46 +01:00
parent 02d76b199a
commit 83432af799
1 changed files with 36 additions and 22 deletions

View File

@ -119,10 +119,6 @@ QskArcMetrics QskArcMetrics::toAbsolute( qreal radius ) const noexcept
QPainterPath QskArcMetrics::painterPath( const QRectF& ellipseRect ) const
{
/*
We might want to have no connecting line between inner and
outer border. F.e. for 360° arcs. TODO ...
*/
const auto sz = qMin( ellipseRect.width(), ellipseRect.height() );
qreal t = m_thickness;
@ -141,11 +137,28 @@ QPainterPath QskArcMetrics::painterPath( const QRectF& ellipseRect ) const
if ( innerRect.isEmpty() )
{
// a pie
if ( qAbs( m_spanAngle ) >= 360.0 )
{
path.addEllipse( ellipseRect );
}
else
{
// pie
path.arcMoveTo( ellipseRect, m_startAngle );
path.arcTo( ellipseRect, m_startAngle, m_spanAngle );
path.lineTo( ellipseRect.center() );
path.closeSubpath();
}
}
else
{
if ( qAbs( m_spanAngle ) >= 360.0 )
{
path.addEllipse( ellipseRect );
QPainterPath innerPath;
innerPath.addEllipse( innerRect );
path -= innerPath;
}
else
{
@ -162,9 +175,10 @@ QPainterPath QskArcMetrics::painterPath( const QRectF& ellipseRect ) const
path.lineTo( pos );
path.arcTo( innerRect, m_startAngle + m_spanAngle, -m_spanAngle );
}
path.closeSubpath();
}
}
return path;
}