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

TimeFade.H

Go to the documentation of this file.
00001 
00010 #ifndef TIMEFADE_H
00011 #define TIMEFADE_H
00012 
00013 #include "Color.H"
00014 
00015 // Gluebase includes
00016 #define OUTSIDE_GLUE_CORE
00017 #include <std/time.H>
00018 
00019 
00020 class TimeFade
00021 {
00022  public:
00023   TimeFade(double startTime, Color startCol,
00024        double endTime, Color endCol) {
00025     _startTime = startTime;
00026     _startCol = startCol;
00027     _endTime = endTime;
00028     _endCol = endCol;
00029   }
00030 
00031   virtual ~TimeFade() {}
00032 
00033   Color getColor() {
00034     return getColor(the_time());
00035   }
00036 
00037   Color getColor(double t) {
00038     float f = (t - _startTime) / (_endTime - _startTime);
00039     if (f < 0.0) f = 0.0;
00040     else if (f > 1.0) f = 1.0;
00041     float f2 = 1.0 - f;
00042     float r = _startCol.r()*f2 + _endCol.r()*f;
00043     float g = _startCol.g()*f2 + _endCol.g()*f;
00044     float b = _startCol.b()*f2 + _endCol.b()*f;
00045     float a = _startCol.a()*f2 + _endCol.a()*f;
00046     return Color(r,g,b,a);
00047   }
00048 
00049  protected:
00050 
00051   double _startTime;
00052   Color  _startCol;
00053   double _endTime;
00054   Color  _endCol;
00055 
00056 };
00057 
00058 #endif

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18