aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/math.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2024-03-05 14:48:59 +0100
committerdelta <darkussdelta@gmail.com>2024-03-05 14:48:59 +0100
commit510ef8e178929cf5e0c7fd5a5120fecf5f1b79f2 (patch)
tree3582e5cd7d000335ca94f2a009f3aed57bd86919 /.config/awesome/quarrel/math.lua
parent95ba8030f722a616cff06c122dcfb2f63e25cf45 (diff)
idk anymore
Diffstat (limited to '.config/awesome/quarrel/math.lua')
-rw-r--r--.config/awesome/quarrel/math.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/.config/awesome/quarrel/math.lua b/.config/awesome/quarrel/math.lua
index 886ce13..b16547b 100644
--- a/.config/awesome/quarrel/math.lua
+++ b/.config/awesome/quarrel/math.lua
@@ -1,5 +1,10 @@
+local gmath = require "gears.math"
+
+---@class QuarrelMath
local qmath = {}
+-- TODO: Finish documenting these functions
+
function qmath.step_value(value, steps)
if value > steps[#steps - 1][1] then
return steps[#steps - 1][2]
@@ -15,6 +20,10 @@ 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.percentage(value, max)
+ return gmath.round(value / max * 100)
+end
+
function qmath.clamp(value, min, max)
return math.max(math.min(value, max), min)
end