annotate doodle/tk/misc.d @ 28:1754cb773d41

Part-way through getting to compile with configure/builder.
author Graham St Jack <graham.stjack@internode.on.net>
date Sun, 02 Aug 2009 16:27:21 +0930
parents tk/misc.d@06c30d250c0a
children 960b408d3ac5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
1 module tk.misc;
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
2
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
3 double min(in double a, in double b) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
4 return a < b ? a : b;
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
5 }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
6
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
7 double max(in double a, in double b) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
8 return a > b ? a : b;
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
9 }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
10
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
11 double clamp(in double v, in double min, in double max) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
12 assert(min < max);
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
13
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
14 if (v < min) { return min; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
15 else if (v > max) { return max; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
16 else { return v; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
17 }