aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/math.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/quarrel/math.lua')
-rw-r--r--.config/awesome/quarrel/math.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/.config/awesome/quarrel/math.lua b/.config/awesome/quarrel/math.lua
new file mode 100644
index 0000000..bc1f53b
--- /dev/null
+++ b/.config/awesome/quarrel/math.lua
@@ -0,0 +1,19 @@
+local qmath = {}
+
+function qmath.step_value(value, steps)
+ for i, step in ipairs(steps) do
+ if step[1] <= value and value <= steps[i + 1][1] then
+ return step[2]
+ end
+ end
+end
+
+function qmath.translate_range(value, in_min, in_max, out_min, out_max)
+ return out_min + ((out_max - out_min) / (in_max - in_min)) * (value - in_min)
+end
+
+function qmath.clamp(value, min, max)
+ return math.max(math.min(value, max), min)
+end
+
+return qmath