summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/canvas.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-12-14 19:27:22 -0500
committerTavian Barnes <tavianator@gmail.com>2011-12-14 19:52:36 -0500
commitbfbe9e43e108f6816c17b9b7764b75284ac78313 (patch)
tree189f85eeec18a76ccb626e45455fa7e45406db7c /libdimension/dimension/canvas.h
parent7db5342a36341b061a8785a3b349cf0fcad69ebf (diff)
downloaddimension-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/dimension/canvas.h')
-rw-r--r--libdimension/dimension/canvas.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index 48a64c1..ba06b8c 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -26,7 +26,7 @@
#include <stddef.h>
/** A canvas, or image. */
-typedef struct {
+typedef struct dmnsn_canvas {
size_t width; /**< Canvas width. */
size_t height; /**< Canvas height. */
@@ -38,7 +38,7 @@ typedef struct {
* Stored in first-quadrant representation (origin is bottom-left). The pixel
* at (a,b) is accessible as pixels[b*width + a].
*/
- dmnsn_color *pixels;
+ dmnsn_tcolor *pixels;
dmnsn_refcount refcount; /**< @internal Reference count. */
} dmnsn_canvas;
@@ -94,9 +94,9 @@ void dmnsn_canvas_optimize(dmnsn_canvas *canvas,
* @param[in] canvas The canvas to access.
* @param[in] x The x coordinate.
* @param[in] y The y coordinate.
- * @return The color of the canvas at (\p x, \p y).
+ * @return The color of the pixel at (\p x, \p y).
*/
-DMNSN_INLINE dmnsn_color
+DMNSN_INLINE dmnsn_tcolor
dmnsn_canvas_get_pixel(const dmnsn_canvas *canvas, size_t x, size_t y)
{
dmnsn_assert(x < canvas->width && y < canvas->height,
@@ -105,18 +105,18 @@ dmnsn_canvas_get_pixel(const dmnsn_canvas *canvas, size_t x, size_t y)
}
/**
- * Set the color of a pixel.
+ * Set the value of a pixel.
* @param[in,out] canvas The canvas to modify.
* @param[in] x The x coordinate of the pixel.
* @param[in] y The y coordinate of the pixel.
- * @param[in] color The color to set the pixel at (\p x, \p y) to.
+ * @param[in] tcolor The value to set the pixel at (\p x, \p y) to.
*/
void dmnsn_canvas_set_pixel(dmnsn_canvas *canvas, size_t x, size_t y,
- dmnsn_color color);
+ dmnsn_tcolor tcolor);
/**
* Clear a canvas uniformly with a given color.
* @param[in,out] canvas The canvas to erase.
- * @param[in] color The color to paint it with.
+ * @param[in] tcolor The color to paint it with.
*/
-void dmnsn_canvas_clear(dmnsn_canvas *canvas, dmnsn_color color);
+void dmnsn_canvas_clear(dmnsn_canvas *canvas, dmnsn_tcolor tcolor);