1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00
imgproxy/imath/imath.go
2021-05-07 17:10:21 +06:00

41 lines
436 B
Go

package imath
import "math"
func Max(a, b int) int {
if a > b {
return a
}
return b
}
func Min(a, b int) int {
if a < b {
return a
}
return b
}
func MinNonZero(a, b int) int {
switch {
case a == 0:
return b
case b == 0:
return a
}
return Min(a, b)
}
func Round(a float64) int {
return int(math.Round(a))
}
func Scale(a int, scale float64) int {
if a == 0 {
return 0
}
return Round(float64(a) * scale)
}