2015-01-03 07:50:37 +00:00
|
|
|
// Various utilities
|
|
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the maximum value of either x or y.
|
|
|
|
|
func intMax(x, y int) int {
|
|
|
|
|
if (x < y) {
|
|
|
|
|
return y
|
|
|
|
|
} else {
|
|
|
|
|
return x
|
|
|
|
|
}
|
2015-01-05 11:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns the minimum value of either x or y.
|
|
|
|
|
func intMin(x, y int) int {
|
|
|
|
|
if (x > y) {
|
|
|
|
|
return y
|
|
|
|
|
} else {
|
|
|
|
|
return x
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns the value capped between two limits.
|
|
|
|
|
func intMinMax(x, min, max int) int {
|
|
|
|
|
if (x < min) {
|
|
|
|
|
return min
|
|
|
|
|
} else if (x > max) {
|
|
|
|
|
return max
|
|
|
|
|
} else {
|
|
|
|
|
return x
|
|
|
|
|
}
|
2015-01-03 07:50:37 +00:00
|
|
|
}
|