commit d7d10a866df51c219dc06589ab4c0c1704b90bbb
parent 3094d5ae9311818bb7bdceca0e08ccf52832a7df
Author: Mattias Andrée <maandree@kth.se>
Date: Mon, 3 Jul 2017 16:35:20 +0200
blind-cone-gradient: make the singularity's value 0.5
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat:
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/blind-cone-gradient.c b/src/blind-cone-gradient.c
@@ -44,18 +44,22 @@ static int with_multiplier = 0;
y = (TYPE)iy - y1;\
for (ix = 0; ix < width; ix++) {\
x = (TYPE)ix - x1;\
- v = atan2(y, x);\
- v -= u;\
- v += 2 * (TYPE)M_PI;\
- v = mod(v, 2 * (TYPE)M_PI);\
- v /= 2 * (TYPE)M_PI;\
- if (anticlockwise)\
- v = 1 - v;\
- v *= m;\
- if (symmetric) {\
- v = mod(2 * v, (TYPE)2);\
- if (v > 1)\
- v = 2 - v;\
+ if (!x && !y) {\
+ v = 0.5;\
+ } else {\
+ v = atan2(y, x);\
+ v -= u;\
+ v += 2 * (TYPE)M_PI;\
+ v = mod(v, 2 * (TYPE)M_PI);\
+ v /= 2 * (TYPE)M_PI;\
+ if (anticlockwise)\
+ v = 1 - v;\
+ v *= m;\
+ if (symmetric) {\
+ v = mod(2 * v, (TYPE)2);\
+ if (v > 1)\
+ v = 2 - v;\
+ }\
}\
buf[ptr][0] = buf[ptr][1] = buf[ptr][2] = buf[ptr][3] = v;\
if (++ptr == ELEMENTSOF(buf)) {\