better decisions for the direction of filling gradient lines

This commit is contained in:
Uwe Rathmann 2023-02-14 11:19:13 +01:00
parent b8f198a97a
commit 126c276eac
4 changed files with 16 additions and 27 deletions

View File

@ -786,23 +786,15 @@ int QskBoxBasicStroker::fillCount() const
if ( m_metrics.isInsideRounded ) if ( m_metrics.isInsideRounded )
{ {
const auto c = m_metrics.corners;
if ( m_metrics.preferredOrientation == Qt::Horizontal ) if ( m_metrics.preferredOrientation == Qt::Horizontal )
{ {
n += qMax( c[ Qt::TopLeftCorner ].innerStepCount(), n += m_metrics.innerStepCount( Qt::TopLeftCorner, Qt::BottomLeftCorner );
c[ Qt::BottomLeftCorner ].innerStepCount() ); n += m_metrics.innerStepCount( Qt::TopRightCorner, Qt::BottomRightCorner );
n += qMax( c[ Qt::TopRightCorner ].innerStepCount(),
c[ Qt::BottomRightCorner ].innerStepCount() );
} }
else else
{ {
n += qMax( c[ Qt::TopLeftCorner ].innerStepCount(), n += m_metrics.innerStepCount( Qt::TopLeftCorner, Qt::TopRightCorner );
c[ Qt::TopRightCorner ].innerStepCount() ); n += m_metrics.innerStepCount( Qt::BottomLeftCorner, Qt::BottomRightCorner );
n += qMax( c[ Qt::BottomLeftCorner ].innerStepCount(),
c[ Qt::BottomRightCorner ].innerStepCount() );
} }
} }

View File

@ -9,6 +9,15 @@
#include "QskBoxColorMap.h" #include "QskBoxColorMap.h"
#include "QskBoxMetrics.h" #include "QskBoxMetrics.h"
static inline bool qskCanUseHVFiller(
const Qt::Orientations orientations, const QskLinearDirection& dir )
{
if ( !dir.isTilted() )
return orientations & ( dir.isVertical() ? Qt::Vertical : Qt::Horizontal );
return false;
}
namespace namespace
{ {
using namespace QskVertex; using namespace QskVertex;
@ -770,7 +779,7 @@ int QskBoxGradientStroker::lineCount() const
if ( m_metrics.isInsideRounded ) if ( m_metrics.isInsideRounded )
{ {
if ( m_metrics.stepSymmetries && !m_dir.isTilted() ) if ( qskCanUseHVFiller( m_metrics.stepSymmetries, m_dir ) )
{ {
const QskBoxBasicStroker stroker( m_metrics, QskBoxBorderColors(), m_gradient ); const QskBoxBasicStroker stroker( m_metrics, QskBoxBorderColors(), m_gradient );
n += stroker.fillCount(); n += stroker.fillCount();
@ -804,7 +813,7 @@ void QskBoxGradientStroker::setLines( int lineCount, QskVertex::ColoredLine* lin
if ( m_metrics.isInsideRounded ) if ( m_metrics.isInsideRounded )
{ {
if ( m_metrics.stepSymmetries && !m_dir.isTilted() ) if ( qskCanUseHVFiller( m_metrics.stepSymmetries, m_dir ) )
{ {
FillerHV filler( m_metrics ); FillerHV filler( m_metrics );
effectiveCount = filler.setLines( m_gradient, lines ); effectiveCount = filler.setLines( m_gradient, lines );

View File

@ -173,15 +173,6 @@ QskBoxMetrics::QskBoxMetrics( const QRectF& rect,
} }
} }
if ( stepSymmetries == Qt::Horizontal )
{
preferredOrientation = Qt::Horizontal;
}
else if ( stepSymmetries == Qt::Vertical )
{
preferredOrientation = Qt::Vertical;
}
else
{ {
const auto tl = corners[ Qt::TopLeftCorner ].innerStepCount(); const auto tl = corners[ Qt::TopLeftCorner ].innerStepCount();
const auto tr = corners[ Qt::TopRightCorner ].innerStepCount(); const auto tr = corners[ Qt::TopRightCorner ].innerStepCount();

View File

@ -89,10 +89,7 @@ class QskBoxMetrics
*/ */
Qt::Orientations stepSymmetries; Qt::Orientations stepSymmetries;
/* // the direction that needs less contour lines is preferred.
In case stepSymmetries indicates both directions the direction
that needs less steps is preferred.
*/
Qt::Orientation preferredOrientation; Qt::Orientation preferredOrientation;
}; };