aboutsummaryrefslogtreecommitdiff
path: root/utils.c
blob: 4813da58b994f8deb56cf80593d12ce08d077364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <u.h>
#include <libc.h>
#include <draw.h>

int
clamp(int n, int min, int max)
{
	return n < min? min: n > max? max: n;
}

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;
}