aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/TextureRender.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc
index 8c7087f..4623417 100644
--- a/src/FbTk/TextureRender.cc
+++ b/src/FbTk/TextureRender.cc
@@ -111,6 +111,10 @@ struct Vec2 {
111 } 111 }
112}; 112};
113 113
114template <typename T> int sign(T val) {
115 return (T(0) < val) - (val < T(0));
116}
117
114std::vector<char>& getGradientBuffer(size_t size) { 118std::vector<char>& getGradientBuffer(size_t size) {
115 static std::vector<char> buffer; 119 static std::vector<char> buffer;
116 if (buffer.size() < size) 120 if (buffer.size() < size)
@@ -469,10 +473,10 @@ void renderRectangleGradient(bool interlaced,
469 473
470 // check, if the point (x, y) is left or right of the vectors 474 // check, if the point (x, y) is left or right of the vectors
471 // 'a' and 'b'. if the point is on the same side for both 'a' and 475 // 'a' and 'b'. if the point is on the same side for both 'a' and
472 // 'b' (a.cross() is equal to b.cross()) then use the y_gradient, 476 // 'b' (a.cross() is equal to b.cross()) then use the x_gradient,
473 // otherwise use y_gradient 477 // otherwise use y_gradient
474 478
475 if ((a.cross(x, y) * b.cross(x, b.y + y)) < 0) { 479 if (sign(a.cross(x, y)) * sign(b.cross(x, b.y + y)) < 0) {
476 rgba[i] = x_gradient[x]; 480 rgba[i] = x_gradient[x];
477 } else { 481 } else {
478 rgba[i] = y_gradient[y]; 482 rgba[i] = y_gradient[y];