QskGradient::qtStops added
This commit is contained in:
parent
4ca794f7db
commit
d5ba7d9504
@ -693,6 +693,17 @@ QskGradientStops QskGradient::colorStops(
|
|||||||
return qskColorStops( rgb.constData(), count, discrete );
|
return qskColorStops( rgb.constData(), count, discrete );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGradientStops QskGradient::qtStops() const
|
||||||
|
{
|
||||||
|
QGradientStops qstops;
|
||||||
|
qstops.reserve( m_stops.count() );
|
||||||
|
|
||||||
|
for ( const auto& stop : m_stops )
|
||||||
|
qstops += { stop.position(), stop.color() };
|
||||||
|
|
||||||
|
return qstops;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
@ -101,6 +101,8 @@ class QSK_EXPORT QskGradient
|
|||||||
Q_INVOKABLE QColor colorAt( int index ) const;
|
Q_INVOKABLE QColor colorAt( int index ) const;
|
||||||
Q_INVOKABLE int stopCount() const;
|
Q_INVOKABLE int stopCount() const;
|
||||||
|
|
||||||
|
QGradientStops qtStops() const;
|
||||||
|
|
||||||
static QskGradientStops colorStops(
|
static QskGradientStops colorStops(
|
||||||
const QVector< QRgb >&, bool discrete = false );
|
const QVector< QRgb >&, bool discrete = false );
|
||||||
|
|
||||||
|
@ -16,12 +16,6 @@ void QskArcRenderer::renderArc(const QRectF& rect,
|
|||||||
{
|
{
|
||||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||||
|
|
||||||
QGradientStops stops;
|
|
||||||
stops.reserve( gradient.stops().count() );
|
|
||||||
|
|
||||||
for( const auto& stop : qAsConst( gradient.stops() ) )
|
|
||||||
stops += QGradientStop( stop.position(), stop.color() );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
horizontal is interpreted as in direction of the arc,
|
horizontal is interpreted as in direction of the arc,
|
||||||
while vertical means from the inner to the outer border
|
while vertical means from the inner to the outer border
|
||||||
@ -31,17 +25,17 @@ void QskArcRenderer::renderArc(const QRectF& rect,
|
|||||||
|
|
||||||
if( gradient.orientation() == QskGradient::Vertical )
|
if( gradient.orientation() == QskGradient::Vertical )
|
||||||
{
|
{
|
||||||
QRadialGradient gradient( rect.center(), qMin( rect.width(), rect.height() ) );
|
QRadialGradient radial( rect.center(), qMin( rect.width(), rect.height() ) );
|
||||||
gradient.setStops( stops );
|
radial.setStops( gradient.qtStops() );
|
||||||
|
|
||||||
brush = gradient;
|
brush = radial;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QConicalGradient gradient( rect.center(), metrics.startAngle() );
|
QConicalGradient conical( rect.center(), metrics.startAngle() );
|
||||||
gradient.setStops( stops );
|
conical.setStops( gradient.qtStops() );
|
||||||
|
|
||||||
brush = gradient;
|
brush = conical;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user