aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/utils.c b/utils.c
new file mode 100644
index 0000000..4f75298
--- /dev/null
+++ b/utils.c
@@ -0,0 +1,18 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+double
+fclamp(double n, double min, double max)
+{
+ return n < min? min: n > max? max: n;
+}
+
+int
+alphachan(ulong chan)
+{
+ for(; chan; chan >>= 8)
+ if(TYPE(chan) == CAlpha)
+ return 1;
+ return 0;
+}