summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-15 23:31:11 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-15 23:31:11 -0400
commitcdaacf47797665a1558006a0fd0d801f65c30c92 (patch)
tree55b779fde719827f77aa6032022621b0ed009394
parentcb85f91c28be53b4436d4cb4ff3ce4c87f501ba3 (diff)
downloaddimension-cdaacf47797665a1558006a0fd0d801f65c30c92.tar.xz
Fix canvas_pigments with negative coordinates.
-rw-r--r--libdimension/canvas_pigment.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libdimension/canvas_pigment.c b/libdimension/canvas_pigment.c
index ad68fe1..8667e4d 100644
--- a/libdimension/canvas_pigment.c
+++ b/libdimension/canvas_pigment.c
@@ -44,13 +44,10 @@ dmnsn_canvas_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v)
dmnsn_canvas *canvas = pigment->ptr;
- int x = v.x*(canvas->x - 1) + 0.5;
- int y = v.x*(canvas->x - 1) + 0.5;
- if (x >= 0 && y >= 0 && x < canvas->x && y < canvas->y) {
- return dmnsn_get_pixel(canvas, x, y);
- } else {
- return dmnsn_black;
- }
+ 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);
+ return c;
}
static void