From b2e1763c7d54e76a49f6f4434996f37882ae2171 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 18 Sep 2011 14:04:19 -0400 Subject: Round correctly when converting colors to integers. --- libdimension/canvas_pigment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libdimension/canvas_pigment.c') diff --git a/libdimension/canvas_pigment.c b/libdimension/canvas_pigment.c index 3ab9de4..8a7e7d3 100644 --- a/libdimension/canvas_pigment.c +++ b/libdimension/canvas_pigment.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2010 Tavian Barnes * + * Copyright (C) 2010-2011 Tavian Barnes * * * * This file is part of The Dimension Library. * * * @@ -31,8 +31,8 @@ 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->width - 1) + 0.5; - int y = (fmod(v.y, 1.0) + 1.0)*(canvas->height - 1) + 0.5; + size_t x = llround((fmod(v.x, 1.0) + 1.0)*(canvas->width - 1)); + size_t y = llround((fmod(v.y, 1.0) + 1.0)*(canvas->height - 1)); dmnsn_color c = dmnsn_get_pixel(canvas, x%canvas->width, y%canvas->height); return c; } -- cgit v1.2.3