00001 /* 00002 00003 ************************************************************************* 00004 00005 ArmageTron -- Just another Tron Lightcycle Game in 3D. 00006 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) 00007 00008 ************************************************************************** 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 00024 *************************************************************************** 00025 00026 */ 00027 00028 #ifndef ArmageTron_rGRADIENT_H 00029 #define ArmageTron_rGRADIENT_H 00030 00031 #include "defs.h" 00032 #include "rColor.h" 00033 #include "tCoord.h" 00034 #include "rTexture.h" 00035 #include <map> 00036 #include <deque> 00037 #include <utility> 00038 00040 class rGradient: public std::map<float, rColor> { 00041 int m_dir; 00042 float m_at; 00043 tCoord m_origin; 00044 tCoord m_dimensions; 00045 tCoord m_texScale; 00046 00048 float GetGradientPt(tCoord const &where); 00051 rColor GetColor(float where); 00052 00053 rResourceTexture m_tex; 00054 public: 00055 rGradient(); 00056 ~rGradient(); 00057 00059 enum direction { 00060 horizontal, 00061 vertical, 00062 value 00063 }; 00066 void SetDir(direction dir) { m_dir = dir; } 00069 void SetValue(float at) { m_at = at; } 00071 void SetGradientEdges(tCoord const &edge1, tCoord const edge2); 00072 00075 void DrawAt(tCoord const &where); 00076 00078 void SetValues(tCoord const &where, float *position, float *color, float *texcoords); 00079 00081 void DrawAtomicRect(tCoord const &edge1, tCoord const &edge2); 00083 void DrawRect(tCoord const &edge1, tCoord const &edge2); 00085 void DrawPoint(tCoord const &where); 00086 00088 void BeginDraw(); 00089 00091 void SetTexture(rResourceTexture const &tex) {m_tex = tex;} 00092 void SetTextureScale(tCoord const &scale) {m_texScale = scale;} 00093 }; 00094 00095 #endif