annotate doodle/tk/misc.d @ 44:2b9329ed0f0e

Added backtrace support
author "David Bryant <bagnose@gmail.com>"
date Sun, 01 Aug 2010 02:06:14 +0930
parents 960b408d3ac5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
960b408d3ac5 Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents: 28
diff changeset
1 module doodle.tk.misc;
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
2
44
2b9329ed0f0e Added backtrace support
"David Bryant <bagnose@gmail.com>"
parents: 29
diff changeset
3 // TODO move this to core
2b9329ed0f0e Added backtrace support
"David Bryant <bagnose@gmail.com>"
parents: 29
diff changeset
4
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
5 double min(in double a, in double b) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
6 return a < b ? a : b;
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
7 }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
8
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
9 double max(in double a, in double b) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
10 return a > b ? a : b;
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
11 }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
12
26
06c30d250c0a Cleanup
"David Bryant <bagnose@gmail.com>"
parents: 0
diff changeset
13 double clamp(in double v, in double min, in double max) {
0
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
14 assert(min < max);
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
15
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
16 if (v < min) { return min; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
17 else if (v > max) { return max; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
18 else { return v; }
e907d2c54ec3 Initial import
David Bryant <daveb@acres.com.au>
parents:
diff changeset
19 }