]> git.tdb.fi Git - libs/demoscene.git/blob - source/colorfade.cpp
Initial files lifted from the Skrolliparty 2 demo
[libs/demoscene.git] / source / colorfade.cpp
1 #include "colorfade.h"
2
3 using namespace Msp;
4
5 ColorFadeAction::ColorFadeAction(const GL::Color &c):
6         Sequencer::InterpolationAction(true),
7         end_color(c)
8 { }
9
10 void ColorFadeAction::start(float b, float d)
11 {
12         start_color = get_color();
13         if(!start_color.a)
14                 start_color = GL::Color(end_color.r, end_color.g, end_color.b, 0.0f);
15         if(!end_color.a)
16                 end_color = GL::Color(start_color.r, start_color.g, start_color.b, 0.0f);
17         InterpolationAction::start(b, d);
18 }
19
20 void ColorFadeAction::interpolate(float t, float)
21 {
22         GL::Color c = start_color*(1-t)+end_color*t;
23         c.a = start_color.a*(1-t)+end_color.a*t;
24         set_color(c);
25 }