From c867406aafaf2385fe1f489c812145e4b96ca1e4 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 14 Jan 2022 10:19:45 +0100 Subject: [PATCH] turn around gradients --- examples/boxes/main.cpp | 20 +++++++++++--------- src/nodes/QskBoxRendererEllipse.cpp | 5 ++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/boxes/main.cpp b/examples/boxes/main.cpp index dc240122..b2135e82 100644 --- a/examples/boxes/main.cpp +++ b/examples/boxes/main.cpp @@ -397,18 +397,18 @@ static void addColoredBorderRectangles3( QskLinearBox* parent, bool rounded ) { 0.6, Qt::magenta }, { 1.0, Qt::green } } ); QskGradient gradient2( Qt::Vertical, { { 0.0, Qt::darkYellow }, - { 0.3, Qt::darkGray }, + { 0.2, Qt::cyan }, { 1.0, Qt::darkMagenta } } ); - QskGradient gradient3( Qt::Vertical, { { 0.0, Qt::darkGreen }, - { 0.25, Qt::darkBlue }, - { 0.5, Qt::darkRed }, - { 0.75, Qt::yellow }, - { 1.0, Qt::magenta } } ); + QskGradient gradient3( Qt::Vertical, { { 0.0, Qt::red }, + { 0.25, Qt::green }, + { 0.5, Qt::blue }, + { 0.75, Qt::magenta }, + { 1.0, Qt::cyan } } ); QskGradient gradient4( Qt::Vertical, { { 0.0, Qt::red }, { 0.3, Qt::green }, { 0.7, Qt::blue }, { 1.0, Qt::cyan } } ); - box->setBorderGradients( gradient1, gradient2, gradient3, gradient4 ); + box->setBorderGradients( gradient3, gradient3, gradient3, gradient3 ); if( rounded ) box->setShape( 30, Qt::AbsoluteSize ); @@ -530,8 +530,10 @@ int main( int argc, char* argv[] ) auto* tab5 = new QskLinearBox( Qt::Horizontal, 5 ); tab5->setMargins( 20 ); tab5->setSpacing( 20 ); - addColoredBorderRectangles1( tab5, false ); - addColoredBorderRectangles1( tab5, true ); +// addColoredBorderRectangles1( tab5, false ); +// addColoredBorderRectangles1( tab5, true ); + addColoredBorderRectangles3( tab5, false ); + addColoredBorderRectangles3( tab5, true ); window.addItem( tab5 ); #endif diff --git a/src/nodes/QskBoxRendererEllipse.cpp b/src/nodes/QskBoxRendererEllipse.cpp index 23df3ed4..a73ec8c1 100644 --- a/src/nodes/QskBoxRendererEllipse.cpp +++ b/src/nodes/QskBoxRendererEllipse.cpp @@ -560,8 +560,7 @@ namespace for( int l = 1; l <= additionalStopCount; ++l ) { - auto p = s.at( l ).position(); - // ### umdrehen: + auto p = ( 1 - s.at( l ).position() ); float xStart = x11 + p * ( x21 - x11 ), yStart = y11 + p * ( y21 - y11 ), xEnd = x12 + p * ( x22 - x12 ), @@ -571,7 +570,7 @@ namespace qDebug() << " end:" << x21 << y21 << x22 << y22; qDebug() << " gradient stop:" << xStart << yStart << xEnd << yEnd; - lines[ l ].setLine( xStart, yStart, xEnd, yEnd, s.at( l ).color() ); + lines[ additionalStopCount - l + 1 ].setLine( xStart, yStart, xEnd, yEnd, s.at( l ).color() ); } }