summaryrefslogtreecommitdiffstats
path: root/libdimension/canvas_pigment.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-14 21:20:43 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-14 21:20:43 -0500
commit8fe33a340b8979a73fa84f201c15519a9b5d0266 (patch)
tree12cdbb1c1b9a48f533ab36980602785be1e1deeb /libdimension/canvas_pigment.c
parent20a55aa78050d94b187d4edfaac91ea00efea505 (diff)
downloaddimension-8fe33a340b8979a73fa84f201c15519a9b5d0266.tar.xz
Document libdimension with Doxygen.
Diffstat (limited to 'libdimension/canvas_pigment.c')
-rw-r--r--libdimension/canvas_pigment.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/libdimension/canvas_pigment.c b/libdimension/canvas_pigment.c
index c86fc66..a1820c4 100644
--- a/libdimension/canvas_pigment.c
+++ b/libdimension/canvas_pigment.c
@@ -18,25 +18,14 @@
* <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "dimension.h"
-
-/* Canvas color pigment callback */
-static dmnsn_color dmnsn_canvas_pigment_fn(const dmnsn_pigment *pigment,
- dmnsn_vector v);
-static void dmnsn_canvas_pigment_free_fn(void *ptr);
+/**
+ * @file
+ * Image maps.
+ */
-/* Create a canvas color */
-dmnsn_pigment *
-dmnsn_new_canvas_pigment(dmnsn_canvas *canvas)
-{
- dmnsn_pigment *pigment = dmnsn_new_pigment();
- pigment->pigment_fn = &dmnsn_canvas_pigment_fn;
- pigment->free_fn = &dmnsn_canvas_pigment_free_fn;
- pigment->ptr = canvas;
- return pigment;
-}
+#include "dimension.h"
-/* Canvas color callback */
+/** Canvas pigment color callback. */
static dmnsn_color
dmnsn_canvas_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v)
{
@@ -44,14 +33,26 @@ dmnsn_canvas_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v)
dmnsn_canvas *canvas = pigment->ptr;
- int x = (fmod(v.x, 1.0) + 1.0)*(canvas->x - 1) + 0.5;
- int y = (fmod(v.y, 1.0) + 1.0)*(canvas->y - 1) + 0.5;
- dmnsn_color c = dmnsn_get_pixel(canvas, x%canvas->x, y%canvas->y);
+ int x = (fmod(v.x, 1.0) + 1.0)*(canvas->width - 1) + 0.5;
+ int y = (fmod(v.y, 1.0) + 1.0)*(canvas->height - 1) + 0.5;
+ dmnsn_color c = dmnsn_get_pixel(canvas, x%canvas->width, y%canvas->height);
return c;
}
+/** Canvas pigment destructor. */
static void
dmnsn_canvas_pigment_free_fn(void *ptr)
{
dmnsn_delete_canvas(ptr);
}
+
+/* Create a canvas color */
+dmnsn_pigment *
+dmnsn_new_canvas_pigment(dmnsn_canvas *canvas)
+{
+ dmnsn_pigment *pigment = dmnsn_new_pigment();
+ pigment->pigment_fn = &dmnsn_canvas_pigment_fn;
+ pigment->free_fn = &dmnsn_canvas_pigment_free_fn;
+ pigment->ptr = canvas;
+ return pigment;
+}