CrystalSpace

Public API Reference

ivaria/gradient.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2003 by Jorrit Tyberghein
00003               (C) 2003 by Frank Richter
00004               (C) 2006 by Christopher Nelson
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __CS_IVARIA_GRADIENT_H__
00022 #define __CS_IVARIA_GRADIENT_H__
00023 
00028 #include "iutil/array.h"
00029 
00030 #include "csutil/cscolor.h"
00031 #include "csgfx/rgbpixel.h"
00032 
00036 struct csGradientShade
00037 {
00039   csColor4 left;
00041   csColor4 right;
00043   float position;
00044   
00046   csGradientShade () : left (0, 0, 0, 1.0f), right (0, 0, 0, 1.0f), 
00047     position (0) {}
00048       
00050   csGradientShade (const csColor4& left_color, const csColor4& right_color, 
00051     float pos)  : left (left_color), right (right_color), position (pos) {}
00053   explicit csGradientShade (const csColor& left_color, 
00054     const csColor& right_color, float pos) : left (left_color), 
00055     right (right_color), position (pos) {}
00056       
00061   csGradientShade (const csColor4& color, float pos) : left (color), 
00062     right (color), position (pos) {}
00067   explicit csGradientShade (const csColor& color, float pos) : 
00068     left (color), right (color), position (pos) {}
00069 
00070   bool operator== (const csGradientShade& other)
00071   { 
00072     return (left == other.left) && (right == other.right)
00073       && (position == other.position);
00074   }
00075 };
00076 
00080 struct iGradientShades : public iArrayReadOnly<csGradientShade>
00081 {
00082   SCF_IARRAYREADONLY_INTERFACE(iGradientShades);
00083 };
00084 
00127 struct iGradient : public virtual iBase
00128 {
00129   SCF_INTERFACE(iGradient, 0, 0, 1);
00130   
00132 
00133   virtual void AddShade (const csGradientShade& shade) = 0;
00134   virtual void AddShade (const csColor4& color, float position) = 0;
00135   virtual void AddShade (const csColor4& left, const csColor4& right, 
00136     float position) = 0;
00138   
00140   virtual void Clear () = 0;
00141   
00158   virtual bool Render (csRGBcolor* pal, size_t count, float begin = 0.0f, 
00159     float end = 1.0f) const = 0;
00160   
00177   virtual bool Render (csRGBpixel* pal, size_t count, float begin = 0.0f, 
00178     float end = 1.0f) const = 0;
00179 
00181   virtual csPtr<iGradientShades> GetShades () = 0;
00182 };
00183 
00184 
00185 #endif // __CS_IVARIA_GRADIENT_H__

Generated for Crystal Space by doxygen 1.4.7