summaryrefslogtreecommitdiff
path: root/src/util/numeric.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/numeric.h')
-rw-r--r--src/util/numeric.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h
index 3e82997bd..076a08efc 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -349,5 +349,12 @@ inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxi
}
}
+inline float cycle_shift(float value, float by = 0, float max = 1)
+{
+ if (value + by < 0) return max + by + value;
+ if (value + by > max) return value + by - max;
+ return value + by;
+}
+
#endif