working more with RGBA values instead of QColor
This commit is contained in:
parent
31577cab9b
commit
615e0016c2
|
@ -233,7 +233,7 @@ QDebug operator<<( QDebug debug, const QskBoxBorderColors& colors )
|
|||
if ( colors.isMonochrome() )
|
||||
{
|
||||
const auto& gradient = colors.gradientAt( Qt::LeftEdge );
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
QskRgb::debugColor( debug, gradient.rgbStart() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ QDebug operator<<( QDebug debug, const QskBoxBorderColors& colors )
|
|||
debug << prompts[ i ] << ": ";
|
||||
|
||||
if ( gradient.isValid() && gradient.isMonochrome() )
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
QskRgb::debugColor( debug, gradient.rgbStart() );
|
||||
else
|
||||
debug << gradient;
|
||||
}
|
||||
|
|
|
@ -609,8 +609,7 @@ QDebug operator<<( QDebug debug, const QskGradient& gradient )
|
|||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
debug << ' ';
|
||||
const auto color = gradient.stops().first().color();
|
||||
QskRgb::debugColor( debug, color );
|
||||
QskRgb::debugColor( debug, gradient.rgbStart() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -103,6 +103,9 @@ class QSK_EXPORT QskGradient
|
|||
Q_INVOKABLE QColor startColor() const noexcept;
|
||||
Q_INVOKABLE QColor endColor() const noexcept;
|
||||
|
||||
QRgb rgbStart() const;
|
||||
QRgb rgbEnd() const;
|
||||
|
||||
void setAlpha( int alpha );
|
||||
|
||||
void setSpread( QGradient::Spread );
|
||||
|
@ -218,6 +221,16 @@ inline QColor QskGradient::endColor() const noexcept
|
|||
return m_stops.isEmpty() ? QColor() : m_stops.last().color();
|
||||
}
|
||||
|
||||
inline QRgb QskGradient::rgbStart() const
|
||||
{
|
||||
return m_stops.isEmpty() ? qRgba( 0, 0, 0, 255 ) : m_stops.first().rgb();
|
||||
}
|
||||
|
||||
inline QRgb QskGradient::rgbEnd() const
|
||||
{
|
||||
return m_stops.isEmpty() ? qRgba( 0, 0, 0, 255 ) : m_stops.last().rgb();
|
||||
}
|
||||
|
||||
inline QGradient::Spread QskGradient::spread() const noexcept
|
||||
{
|
||||
return m_spread;
|
||||
|
|
|
@ -50,7 +50,7 @@ static inline QskGradient qskEffectiveGradient( const QskGradient& gradient )
|
|||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
g.setLinearDirection( Qt::Vertical );
|
||||
g.setStops( gradient.startColor() );
|
||||
g.setStops( gradient.rgbStart() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
|
|||
{
|
||||
if ( isFillMonochrome && isBorderMonochrome )
|
||||
{
|
||||
if ( borderColors.left().startColor() == fillGradient.startColor() )
|
||||
if ( borderColors.left().rgbStart() == fillGradient.rgbStart() )
|
||||
{
|
||||
// we can draw border and background in one
|
||||
hasBorder = false;
|
||||
|
@ -246,12 +246,12 @@ void QskBoxNode::setBoxData( const QRectF& rect,
|
|||
|
||||
if ( hasFill )
|
||||
{
|
||||
flatMaterial->setColor( fillGradient.startColor() );
|
||||
flatMaterial->setColor( fillGradient.rgbStart() );
|
||||
renderer.renderFill( d->rect, shape, QskBoxBorderMetrics(), *geometry() );
|
||||
}
|
||||
else
|
||||
{
|
||||
flatMaterial->setColor( borderColors.left().startColor().rgba() );
|
||||
flatMaterial->setColor( borderColors.left().rgbStart() );
|
||||
renderer.renderBorder( d->rect, shape, borderMetrics, *geometry() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,13 +261,13 @@ namespace QskVertex
|
|||
{
|
||||
if ( value2 == 1.0 && value1 == 0.0 )
|
||||
{
|
||||
TwoColorIterator01 colorIt( gradient.startColor(), gradient.endColor() );
|
||||
TwoColorIterator01 colorIt( gradient.rgbStart(), gradient.rgbEnd() );
|
||||
line = fillOrdered( contourIt, colorIt, line );
|
||||
}
|
||||
else
|
||||
{
|
||||
TwoColorIterator colorIt( value1, value2,
|
||||
gradient.startColor(), gradient.endColor() );
|
||||
gradient.rgbStart(), gradient.rgbEnd() );
|
||||
|
||||
line = fillOrdered( contourIt, colorIt, line );
|
||||
}
|
||||
|
|
|
@ -500,7 +500,7 @@ namespace
|
|||
{
|
||||
public:
|
||||
inline BorderMapSolid( const QskBoxBorderColors& colors )
|
||||
: m_color( colors.left().startColor() )
|
||||
: m_color( colors.left().rgbStart() )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -515,8 +515,8 @@ namespace
|
|||
public:
|
||||
inline BorderMapGradient( int stepCount, const QskGradient& gradient1, const QskGradient& gradient2 )
|
||||
: m_stepCount( stepCount )
|
||||
, m_color1( gradient1.startColor() )
|
||||
, m_color2( gradient2.endColor() )
|
||||
, m_color1( gradient1.rgbStart() )
|
||||
, m_color2( gradient2.rgbEnd() )
|
||||
, m_gradient( gradient2 )
|
||||
{
|
||||
}
|
||||
|
@ -1037,12 +1037,12 @@ static inline void qskRenderFillRandom(
|
|||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
const ColorMapSolid map( gradient.startColor() );
|
||||
const ColorMapSolid map( gradient.rgbStart() );
|
||||
qskRenderFillLines( metrics, orientation, line, map );
|
||||
}
|
||||
else
|
||||
{
|
||||
const ColorMapGradient map( gradient.startColor(), gradient.endColor() );
|
||||
const ColorMapGradient map( gradient.rgbStart(), gradient.rgbEnd() );
|
||||
qskRenderFillLines( metrics, orientation, line, map );
|
||||
}
|
||||
}
|
||||
|
@ -1059,14 +1059,14 @@ static inline void qskRenderBoxRandom(
|
|||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
const ColorMapSolid fillMap( gradient.startColor() );
|
||||
const ColorMapSolid fillMap( gradient.rgbStart() );
|
||||
qskRenderLines( metrics, Qt::Vertical, borderLine, borderMap, fillLine, fillMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto orientation = qskQtOrientation( gradient );
|
||||
|
||||
const ColorMapGradient fillMap( gradient.startColor(), gradient.endColor() );
|
||||
const ColorMapGradient fillMap( gradient.rgbStart(), gradient.rgbEnd() );
|
||||
qskRenderLines( metrics, orientation, borderLine, borderMap, fillLine, fillMap );
|
||||
}
|
||||
}
|
||||
|
@ -1086,14 +1086,14 @@ static inline void qskRenderBoxRandom(
|
|||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
const ColorMapSolid fillMap( gradient.startColor() );
|
||||
const ColorMapSolid fillMap( gradient.rgbStart() );
|
||||
qskRenderLines( metrics, Qt::Vertical, borderLine, tl, tr, bl, br, fillLine, fillMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto orientation = qskQtOrientation( gradient );
|
||||
|
||||
const ColorMapGradient fillMap( gradient.startColor(), gradient.endColor() );
|
||||
const ColorMapGradient fillMap( gradient.rgbStart(), gradient.rgbEnd() );
|
||||
qskRenderLines( metrics, orientation, borderLine, tl, tr, bl, br, fillLine, fillMap );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -622,7 +622,7 @@ void QskBoxRenderer::renderRect(
|
|||
|
||||
if ( gd.isMonochrome() )
|
||||
{
|
||||
const ColorMapSolid colorMap( gd.startColor() );
|
||||
const ColorMapSolid colorMap( gd.rgbStart() );
|
||||
qskCreateFillRandom( Qt::Vertical, in, colorMap, line );
|
||||
}
|
||||
else
|
||||
|
@ -643,7 +643,7 @@ void QskBoxRenderer::renderRect(
|
|||
const auto orientation = gd.linearDirection().isVertical()
|
||||
? Qt::Vertical : Qt::Horizontal;
|
||||
|
||||
const ColorMapGradient colorMap( gd.startColor(), gd.endColor() );
|
||||
const ColorMapGradient colorMap( gd.rgbStart(), gd.rgbEnd() );
|
||||
qskCreateFillRandom( orientation, in, colorMap, line );
|
||||
}
|
||||
else
|
||||
|
@ -660,7 +660,7 @@ void QskBoxRenderer::renderRect(
|
|||
|
||||
if ( bc.isMonochrome() )
|
||||
{
|
||||
const auto rgb = bc.left().startColor().rgba();
|
||||
const auto rgb = bc.left().rgbStart();
|
||||
qskCreateBorderMonochrome( rect, in, rgb, fillLines );
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue