summaryrefslogtreecommitdiffstats
path: root/compton.h
diff options
context:
space:
mode:
Diffstat (limited to 'compton.h')
-rw-r--r--compton.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/compton.h b/compton.h
index ea906969d..9a8dd8506 100644
--- a/compton.h
+++ b/compton.h
@@ -153,6 +153,23 @@ extern int root_height, root_width;
// http://clang.llvm.org/compatibility.html#inline
/**
+ * Normalize an int value to a specific range.
+ *
+ * @param i int value to normalize
+ * @param min minimal value
+ * @param max maximum value
+ * @return normalized value
+ */
+static inline double normalize_i_range(int i, int min, int max) {
+ if (i > max)
+ return max;
+ if (i < min)
+ return min;
+
+ return i;
+}
+
+/**
* Normalize a double value to 0.\ 0 - 1.\ 0.
*
* @param d double value to normalize