summaryrefslogtreecommitdiff
path: root/pkgs/astal/src/lib.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/astal/src/lib.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkgs/astal/src/lib.lua b/pkgs/astal/src/lib.lua
index 98a5ecc..23c5dd1 100644
--- a/pkgs/astal/src/lib.lua
+++ b/pkgs/astal/src/lib.lua
@@ -103,6 +103,16 @@ lib = {
return lib.count(array) == 0
end,
+ --- clamps a number between two other numbers
+ clamp = function(num, low, high)
+ if low and num < low then
+ return low
+ elseif high and num > high then
+ return high
+ end
+ return num
+ end,
+
--- negates value
neg = function(val)
return not val