diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-12-14 19:27:22 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-12-14 19:52:36 -0500 |
commit | bfbe9e43e108f6816c17b9b7764b75284ac78313 (patch) | |
tree | 189f85eeec18a76ccb626e45455fa7e45406db7c /libdimension/rgba16.c | |
parent | 7db5342a36341b061a8785a3b349cf0fcad69ebf (diff) | |
download | dimension-bfbe9e43e108f6816c17b9b7764b75284ac78313.tar.xz |
Re-think colors.
Color is a property of light, and thus doesn't include information
about transparency. But canvas pixels and object pigments represent
a color and a degree of transparency. The new type dmnsn_tcolor/
TColor encapsulates that information.
Also, fix the transparent shadow implementation.
Diffstat (limited to 'libdimension/rgba16.c')
-rw-r--r-- | libdimension/rgba16.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libdimension/rgba16.c b/libdimension/rgba16.c index 980a2d3..2c7a8d5 100644 --- a/libdimension/rgba16.c +++ b/libdimension/rgba16.c @@ -50,14 +50,13 @@ dmnsn_rgba16_optimizer_fn(const dmnsn_canvas *canvas, dmnsn_canvas_optimizer optimizer, size_t x, size_t y) { uint16_t *pixel = (uint16_t *)optimizer.ptr + 4*(y*canvas->width + x); - dmnsn_color color; - color = dmnsn_canvas_get_pixel(canvas, x, y); - color = dmnsn_remove_filter(color); - color = dmnsn_color_to_sRGB(color); - color = dmnsn_color_saturate(color); + dmnsn_tcolor tcolor = dmnsn_canvas_get_pixel(canvas, x, y); + tcolor = dmnsn_tcolor_remove_filter(tcolor); + tcolor.c = dmnsn_color_to_sRGB(tcolor.c); + tcolor = dmnsn_tcolor_saturate(tcolor); - pixel[0] = lround(color.R*UINT16_MAX); - pixel[1] = lround(color.G*UINT16_MAX); - pixel[2] = lround(color.B*UINT16_MAX); - pixel[3] = lround(color.trans*UINT16_MAX); + pixel[0] = lround(tcolor.c.R*UINT16_MAX); + pixel[1] = lround(tcolor.c.G*UINT16_MAX); + pixel[2] = lround(tcolor.c.B*UINT16_MAX); + pixel[3] = lround(tcolor.T*UINT16_MAX); } |