diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-01-14 12:44:32 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-01-14 12:44:32 -0500 |
commit | 280b84ed9122d6b96555498d8672b5de98286c46 (patch) | |
tree | 684700fcf0fe93adb74a5dd6040c459d46cc40ad /src/sdl/bg-style.c | |
parent | 969c64da6a63e6c0efa1b79a317ef953cb3aaaa9 (diff) | |
download | sok-280b84ed9122d6b96555498d8672b5de98286c46.tar.bz2 sok-280b84ed9122d6b96555498d8672b5de98286c46.zip |
add bg-style.[hc]
Diffstat (limited to 'src/sdl/bg-style.c')
-rw-r--r-- | src/sdl/bg-style.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/sdl/bg-style.c b/src/sdl/bg-style.c new file mode 100644 index 0000000..02bc759 --- /dev/null +++ b/src/sdl/bg-style.c @@ -0,0 +1,21 @@ +#include <math.h> // sin() +#include "bg-style.h" + +#define M_2_PI (2.0 * 3.1415926) + +#define BG_STYLE_GET_CHANNEL(c, time) ((c).base + (((c).period) ? ( \ + (c).amplitude * sin(((c).phase + (time)) * M_2_PI / (1.0 * (c).period)) \ +) : 0)) + +SDL_Color +bg_style_get_color( + const bg_style_t * const style, + const Uint32 ticks +) { + return (SDL_Color) { + .r = BG_STYLE_GET_CHANNEL(style->r, ticks), + .g = BG_STYLE_GET_CHANNEL(style->g, ticks), + .b = BG_STYLE_GET_CHANNEL(style->b, ticks), + .a = BG_STYLE_GET_CHANNEL(style->a, ticks), + }; +} |