aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/math.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2023-04-04 15:43:40 +0200
committerdelta <darkussdelta@gmail.com>2023-04-04 15:43:40 +0200
commitf7116d268aff3fae88d8de408e8c807295618a5c (patch)
tree6f52530d5799769e6af7c63bc5108f16f9aff742 /.config/awesome/quarrel/math.lua
parentf0b32f45746c026d402651013b7e98315d6956a1 (diff)
restructure and improve config
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