TonicTones
|
00001 // Color.cpp 00002 // 00003 // Copyright 2010 Jérémy Laumon <jeremy.laumon@gmail.com> 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program 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 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00018 // MA 02110-1301, USA. 00019 00020 00021 #include <Color.h> 00022 00029 Color::Color(){} 00030 00031 Color::Color(float f1, float f2, float f3) 00032 { 00033 val[0] = f1; 00034 val[1] = f2; 00035 val[2] = f3; 00036 } 00037 00038 Color& Color::operator =(const QVector3D& vect) 00039 { 00040 val[0] = vect.x(); 00041 val[1] = vect.y(); 00042 val[2] = vect.z(); 00043 00044 return *this; 00045 } 00046 00047 Color Color::operator *(float f) const 00048 { 00049 return Color (val[0] * f, 00050 val[1] * f, 00051 val[2] * f); 00052 } 00053 00054 QVector3D Color::toVect() const 00055 { 00056 return QVector3D(val[0],val[1],val[2]); 00057 } 00058 00059 Color Color::clamp() const 00060 { 00061 float min = 0.0; 00062 float max = 1.0; 00063 return Color(qBound(min,val[0],max), 00064 qBound(min,val[1],max), 00065 qBound(min,val[2],max)); 00066 }