Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Color4c.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 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 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * 四要素キャラクタカラー実装
00022  * @author Junpee
00023  */
00024 
00025 #include "LampBasic.h"
00026 #include "Core/Primitive/Color4c.h"
00027 #include "Core/Primitive/Color3c.h"
00028 #include "Core/Primitive/Color3f.h"
00029 #include "Core/Primitive/Color4f.h"
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 // 定数
00035 //------------------------------------------------------------------------------
00036 // 白
00037 const Color4c Color4c::white(255, 255, 255);
00038 
00039 // 灰色
00040 const Color4c Color4c::gray(128, 128, 128);
00041 
00042 // 黒
00043 const Color4c Color4c::black(0, 0, 0);
00044 
00045 // 赤
00046 const Color4c Color4c::red(255, 0, 0);
00047 
00048 // 緑
00049 const Color4c Color4c::green(0, 255, 0);
00050 
00051 // 青
00052 const Color4c Color4c::blue(0, 0, 255);
00053 
00054 // 黄
00055 const Color4c Color4c::yellow(255, 255, 0);
00056 
00057 // 青緑
00058 const Color4c Color4c::cyan(0, 255, 255);
00059 
00060 // 赤紫
00061 const Color4c Color4c::magenta(255, 0, 255);
00062 
00063 //------------------------------------------------------------------------------
00064 // コンストラクタ
00065 Color4c::Color4c(const Color3c& source) :
00066     r(source.r), g(source.g), b(source.b), a(255){
00067 }
00068 //------------------------------------------------------------------------------
00069 // コンストラクタ
00070 Color4c::Color4c(const Color3f& source){
00071     set(source);
00072 }
00073 //------------------------------------------------------------------------------
00074 // コンストラクタ
00075 Color4c::Color4c(const Color4f& source){
00076     set(source);
00077 }
00078 //------------------------------------------------------------------------------
00079 // 三要素キャラクタカラーの設定
00080 void Color4c::set(const Color3c& source){
00081     set(source.r, source.g, source.b, 255);
00082 }
00083 //------------------------------------------------------------------------------
00084 // 三要素実数カラーの設定
00085 void Color4c::set(const Color3f& source){
00086     int srcR = (int)(source.r * 255.f);
00087     if(srcR > 255){ srcR = 255; }
00088     else if(srcR < 0){ srcR = 0; }
00089 
00090     int srcG = (int)(source.g * 255.f);
00091     if(srcG > 255){ srcG = 255; }
00092     else if(srcG < 0){ srcG = 0; }
00093 
00094     int srcB = (int)(source.b * 255.f);
00095     if(srcB > 255){ srcB = 255; }
00096     else if(srcB < 0){ srcB = 0; }
00097 
00098     set(srcR, srcG, srcB, 255);
00099 }
00100 //------------------------------------------------------------------------------
00101 // 四要素実数カラーの設定
00102 void Color4c::set(const Color4f& source){
00103     int srcR = (int)(source.r * 255.f);
00104     if(srcR > 255){ srcR = 255; }
00105     else if(srcR < 0){ srcR = 0; }
00106 
00107     int srcG = (int)(source.g * 255.f);
00108     if(srcG > 255){ srcG = 255; }
00109     else if(srcG < 0){ srcG = 0; }
00110 
00111     int srcB = (int)(source.b * 255.f);
00112     if(srcB > 255){ srcB = 255; }
00113     else if(srcB < 0){ srcB = 0; }
00114 
00115     int srcA = (int)(source.a * 255.f);
00116     if(srcA > 255){ srcA = 255; }
00117     else if(srcA < 0){ srcA = 0; }
00118 
00119     set(srcR, srcG, srcB, srcA);
00120 }
00121 //------------------------------------------------------------------------------
00122 } // End of namespace Lamp
00123 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:29 2005 for Lamp by doxygen 1.3.2