]> git.sesse.net Git - nageru/commitdiff
Fix a problem with visualizing flow that goes exactly left.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 24 Jul 2018 20:56:11 +0000 (22:56 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 24 Jul 2018 20:56:11 +0000 (22:56 +0200)
util.h

diff --git a/util.h b/util.h
index 3693fd22465a0ff2968729cd320aa78d5f3770ad..91ed0a20fa7e765760e8507029b4ecee4a893ab0 100644 (file)
--- a/util.h
+++ b/util.h
@@ -28,17 +28,17 @@ inline void flow2rgb(float du, float dv, uint8_t *rr, uint8_t *gg, uint8_t *bb)
        float h = (angle + M_PI) * 6.0 / (2.0 * M_PI);
        float X = c * (1.0 - fabs(fmod(h, 2.0) - 1.0));
        float r = 0.0f, g = 0.0f, b = 0.0f;
-       if (h < 1.0f) {
+       if (h <= 1.0f) {
                r = c; g = X;
-       } else if (h < 2.0f) {
+       } else if (h <= 2.0f) {
                r = X; g = c;
-       } else if (h < 3.0f) {
+       } else if (h <= 3.0f) {
                g = c; b = X;
-       } else if (h < 4.0f) {
+       } else if (h <= 4.0f) {
                g = X; b = c;
-       } else if (h < 5.0f) {
+       } else if (h <= 5.0f) {
                r = X; b = c;
-       } else if (h < 6.0f) {
+       } else if (h <= 6.0f) {
                r = c; b = X;
        } else {
                // h is NaN, so black is fine.