diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-01 22:54:27 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-01 22:54:27 +0200 |
commit | 8e128e5afd495c46ab54eaff2c602e420eb59c0d (patch) | |
tree | b4cb1e579f80f39db7169c0eb92e3a69181f0ee8 /color.c | |
parent | a2fd89f963a7374b29f7831e67b443c3d42c6e3c (diff) | |
download | nebula2-8e128e5afd495c46ab54eaff2c602e420eb59c0d.tar.gz nebula2-8e128e5afd495c46ab54eaff2c602e420eb59c0d.tar.bz2 nebula2-8e128e5afd495c46ab54eaff2c602e420eb59c0d.zip |
Nebulabrot algo and rendering implemented.
Diffstat (limited to 'color.c')
-rw-r--r-- | color.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,36 @@ +#include "color.h" + +static int +fix_range(int x, int min, int max) { + if(x < min) { + return min; + } + if(x > max) { + return max; + } + return x; +} + +color_t +color_fix(color_t col) { + col.r = fix_range(col.r, 0, 255); + col.g = fix_range(col.g, 0, 255); + col.b = fix_range(col.b, 0, 255); + return col; +} + +color_t +color_add(color_t a, color_t b) { + a.r += b.r; + a.g += b.g; + a.b += b.b; + return a; +} + +color_t +color_mul(color_t col, double s) { + col.r = ((double) col.r) * s; + col.g = ((double) col.g) * s; + col.b = ((double) col.b) * s; + return col; +} |