From fbabe1a0cf8034dc1191d6e3e6253319bf35ea82 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Tue, 11 May 2010 01:18:29 +0000 Subject: [PATCH] Improved decoration shadows: - the number of points on the gradient depends on the shadow size - analytical functions (fitted to previous hard-coded values) are used to calculate the gradients. Inner gradient is parabolic; mid and outer gradients are gaussian. svn path=/trunk/KDE/kdebase/workspace/; revision=1125232 --- clients/oxygen/oxygenshadowcache.cpp | 81 ++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 22 deletions(-) diff --git a/clients/oxygen/oxygenshadowcache.cpp b/clients/oxygen/oxygenshadowcache.cpp index c75fb32868..126aa42f84 100644 --- a/clients/oxygen/oxygenshadowcache.cpp +++ b/clients/oxygen/oxygenshadowcache.cpp @@ -29,6 +29,7 @@ #include "oxygenhelper.h" #include +#include #include #include #include @@ -36,6 +37,10 @@ namespace Oxygen { + //_______________________________________________________ + qreal sqr( qreal x ) + { return x*x; } + //_______________________________________________________ ShadowCache::ShadowCache( DecoHelper& helper ): helper_( helper ), @@ -173,11 +178,11 @@ namespace Oxygen { + // inner (shark) gradient const qreal gradientSize = qMin( shadowSize, (shadowSize+fixedSize)/2 ); const qreal hoffset = shadowConfiguration.horizontalOffset()*gradientSize/fixedSize; const qreal voffset = shadowConfiguration.verticalOffset()*gradientSize/fixedSize; - // inner (shark) gradient const int nPoints = 7; const qreal x[7] = {0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.4 }; const qreal values[7] = {0.8, 0.78, 0.69, 0.42, 0.18, 0.01, 0 }; @@ -193,11 +198,11 @@ namespace Oxygen { + // outer (spread) gradient const qreal gradientSize = shadowSize; const qreal hoffset = shadowConfiguration.horizontalOffset()*gradientSize/fixedSize; const qreal voffset = shadowConfiguration.verticalOffset()*gradientSize/fixedSize; - // outer (spread) gradient const int nPoints = 7; const qreal x[7] = {0, 0.15, 0.3, 0.45, 0.65, 0.75, 1 }; const qreal values[7] = {0.47, 0.37, 0.2, 0.08, 0.04, 0.02, 0 }; @@ -214,19 +219,32 @@ namespace Oxygen } else { { + // inner (sharp gradient) const qreal gradientSize = qMin( shadowSize, fixedSize ); const qreal hoffset = shadowConfiguration.horizontalOffset()*gradientSize/fixedSize; const qreal voffset = shadowConfiguration.verticalOffset()*gradientSize/fixedSize; - // inner (sharp gradient) - const int nPoints = 5; - const qreal x[5] = { 0, 4.5, 5.0, 5.5, 6.5 }; - const qreal values[5] = { 1.0, 0.32, 0.22, 0.03, 0 }; - QRadialGradient rg = QRadialGradient( size+hoffset, size+voffset, gradientSize ); - QColor c = shadowConfiguration.innerColor(); - for( int i = 0; i