KStyles
colorutil.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "colorutil.h"
00022
00023 #include <QtGui/QColor>
00024
00025 namespace Keramik
00026 {
00027 QColor ColorUtil::lighten(const QColor& in, int factor)
00028 {
00029 if (factor > 100)
00030 {
00031 int h, s, v;
00032 in.getHsv(&h, &s, &v);
00033
00034 float mShare = v/230.0;
00035 if (mShare > 1) mShare = 1;
00036
00037 mShare *= mShare;
00038
00039 int diff = factor - 100;
00040 int hd = int(mShare*diff);
00041 int delta = int((diff - hd)*7.55);
00042
00043 QColor wrk = in.light(100+hd);
00044
00045 int r = wrk.red();
00046 int g = wrk.green();
00047 int b = wrk.blue();
00048
00049 r+=delta;
00050 g+=delta;
00051 b+=delta;
00052
00053 if (r>255) r=255;
00054 if (g>255) g=255;
00055 if (b>255) b=255;
00056
00057 return QColor(r,g,b);
00058 }
00059
00060 return in;
00061 }
00062 }
00063
00064