diff options
author | Julian T <julian@jtle.dk> | 2020-02-21 14:42:42 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-02-21 14:42:42 +0100 |
commit | 9b40029e42f994aeff59ecc44a6d3b8fba93071d (patch) | |
tree | c133f8f6190b445560c4d8438ba89d7caaa0a7cd /pgm.c | |
parent | 623fee395425ab33f14fb9cd8ffa790e362f59d7 (diff) |
Pretty realistic colors
Diffstat (limited to 'pgm.c')
-rw-r--r-- | pgm.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -25,3 +25,42 @@ color_t *color_set(color_t *c, uint8_t r, uint8_t g, uint8_t b) return c; } + +color_t *color_add(color_t *dest, color_t *a, color_t *b) +{ + if (!dest) { + dest = (color_t *) malloc(sizeof(dest)); + } + + dest->r = a->r + b->r; + dest->g = a->g + b->g; + dest->b = a->b + b->b; + + return dest; +} + +color_t *color_scale(color_t *dest, color_t *a, float b) +{ + if (!dest) { + dest = (color_t *) malloc(sizeof(dest)); + } + + dest->r = a->r * b; + dest->g = a->g * b; + dest->b = a->b * b; + + return dest; +} + +color_t *color_scale_vector(color_t *dest, color_t *a, vector_t *v) +{ + if (!dest) { + dest = (color_t *) malloc(sizeof(dest)); + } + + dest->r = a->r * v->x; + dest->g = a->g * v->y; + dest->b = a->b * v->z; + + return dest; +} |