summaryrefslogtreecommitdiffstats
path: root/libdimension/canvas_pigment.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-09-18 14:04:19 -0400
committerTavian Barnes <tavianator@gmail.com>2011-09-18 14:04:19 -0400
commitb2e1763c7d54e76a49f6f4434996f37882ae2171 (patch)
treecefad99c5d5d2724d432c43ef762bc9e23f2eb2e /libdimension/canvas_pigment.c
parent126211b917626fe7531310971981ee5d06026625 (diff)
downloaddimension-b2e1763c7d54e76a49f6f4434996f37882ae2171.tar.xz
Round correctly when converting colors to integers.
Diffstat (limited to 'libdimension/canvas_pigment.c')
-rw-r--r--libdimension/canvas_pigment.c6
1 files changed, 3 insertions, 3 deletions
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 <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
* *
* 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;
}