diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kcoloredit/color.cpp | |
download | tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcoloredit/color.cpp')
-rw-r--r-- | kcoloredit/color.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/kcoloredit/color.cpp b/kcoloredit/color.cpp new file mode 100644 index 00000000..db18a5a5 --- /dev/null +++ b/kcoloredit/color.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + color.cpp - description + ------------------- + begin : Sun Jul 9 2000 + copyright : (C) 2000 by Artur Rataj + email : art@zeus.polsl.gliwice.pl + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "color.h" + +Color::Color(){ + setComponents(0, 0, 0); + setName(""); +} +Color::Color(const int red, const int green, const int blue, const QString& name) { + setComponents(red, green, blue); + setName(name); +} +Color::~Color(){ +} + +void Color::setComponent(const int index, const int value) { + m_components[index] = value; +} + +void Color::setComponents(const int red, const int green, const int blue) { + setComponent(RED_INDEX, red); + setComponent(GREEN_INDEX, green); + setComponent(BLUE_INDEX, blue); +} + +void Color::setName(const QString& name) { + m_name = name; +} + +int Color::component(const int index) const { + return m_components[index]; +} + +const int* Color::components() const{ + return m_components; +} + +const QString& Color::name() const { + return m_name; +} + +bool Color::equals(const Color& color) { + return component(RED_INDEX) == color.component(RED_INDEX) && + component(GREEN_INDEX) == color.component(GREEN_INDEX) && + component(BLUE_INDEX) == color.component(BLUE_INDEX); +} + +void Color::modifyComponent(const int index, const int value, const double amount) { + int comp = component(index); + comp += (int)(value*amount + 0.5); + if(comp > RGB_MAX_COMPONENT_VALUE) + comp = RGB_MAX_COMPONENT_VALUE; + else if(comp < 0) + comp = 0; + setComponent(index, comp); +} + +void Color::modifyComponents(const int red, const int green, const int blue, const double amount) { + modifyComponent(RED_INDEX, red, amount); + modifyComponent(GREEN_INDEX, green, amount); + modifyComponent(BLUE_INDEX, blue, amount); +} + |