Mercurial > projects > doodle
annotate tk/misc.d @ 0:e907d2c54ec3
Initial import
author | David Bryant <daveb@acres.com.au> |
---|---|
date | Wed, 13 May 2009 15:42:39 +0930 |
parents | |
children | 06c30d250c0a |
rev | line source |
---|---|
0 | 1 module tk.misc; |
2 | |
3 double min(double a, double b) { | |
4 return a < b ? a : b; | |
5 } | |
6 | |
7 double max(double a, double b) { | |
8 return a > b ? a : b; | |
9 } | |
10 | |
11 double clamp(double v, double min, double max) { | |
12 assert(min < max); | |
13 | |
14 if (v < min) { return min; } | |
15 else if (v > max) { return max; } | |
16 else { return v; } | |
17 } |