Mercurial > projects > doodle
annotate doodle/core/misc.d @ 77:15ca7d5cd1ed
The rulers are broken
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sun, 15 Aug 2010 01:36:22 +0930 |
parents | 31d10176415d |
children |
rev | line source |
---|---|
67 | 1 module doodle.core.misc; |
2 | |
3 // Basic routines. | |
4 // Note, most of these are probably provided by phobos. | |
5 | |
6 double min(in double a, in double b) { | |
7 return a < b ? a : b; | |
8 } | |
9 | |
10 double max(in double a, in double b) { | |
11 return a > b ? a : b; | |
12 } | |
13 | |
14 double clamp(in double v, in double min, in double max) { | |
15 assert(min < max); | |
16 | |
17 if (v < min) { return min; } | |
18 else if (v > max) { return max; } | |
19 else { return v; } | |
20 } | |
77 | 21 |
22 // wrap? |