From cdaacf47797665a1558006a0fd0d801f65c30c92 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 15 Apr 2010 23:31:11 -0400 Subject: Fix canvas_pigments with negative coordinates. --- libdimension/canvas_pigment.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'libdimension/canvas_pigment.c') 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 -- cgit v1.2.3