• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KStyles

colorutil.cpp

Go to the documentation of this file.
00001 /* Keramik Style for KDE3, color utility routines..
00002    Copyright (c) 2002 Malte Starostik <malte@kde.org>
00003                   (c) 2002 Maksim Orlovich <mo002j@mail.rochester.edu>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
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 // vim: ts=4 sw=4 noet

KStyles

Skip menu "KStyles"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal