]> git.tdb.fi Git - libs/demoscene.git/blob - source/colorfade.cpp
Allow stages to define actions
[libs/demoscene.git] / source / colorfade.cpp
1 #include "colorfade.h"
2
3 namespace Msp {
4 namespace DemoScene {
5
6 ColorFadeAction::ColorFadeAction(const GL::Color &c):
7         InterpolationAction(HERMITE),
8         end_color(c)
9 { }
10
11 void ColorFadeAction::start(float b, float d)
12 {
13         start_color = get_color();
14         if(!start_color.a)
15                 start_color = GL::Color(end_color.r, end_color.g, end_color.b, 0.0f);
16         if(!end_color.a)
17                 end_color = GL::Color(start_color.r, start_color.g, start_color.b, 0.0f);
18         InterpolationAction::start(b, d);
19 }
20
21 void ColorFadeAction::interpolate(float t, float)
22 {
23         GL::Color c = start_color*(1-t)+end_color*t;
24         c.a = start_color.a*(1-t)+end_color.a*t;
25         set_color(c);
26 }
27
28 } // namespace DemoScene
29 } // namespace Msp