route/vendor/github.com/aclements/go-moremath/scale/util.go

17 lines
310 B
Go
Raw Normal View History

2017-10-06 15:29:20 +00:00
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package scale
// clamp clamps x to the range [0, 1].
func clamp(x float64) float64 {
if x < 0 {
return 0
}
if x > 1 {
return 1
}
return x
}