x/mobile/sprite/clock: clamp linear tween

LGTM=hyangah
R=hyangah
CC=golang-codereviews
https://golang.org/cl/175450043
This commit is contained in:
David Crawshaw 2014-11-20 16:45:16 -05:00
parent fb724b9af0
commit 2d225d30b6
1 changed files with 5 additions and 1 deletions

View File

@ -14,10 +14,14 @@ var (
EaseInOut = CubicBezier(0.42, 0, 0.58, 1) EaseInOut = CubicBezier(0.42, 0, 0.58, 1)
) )
// Linear computes the fraction [0,1] that t lies between [t0,t1].
func Linear(t0, t1, t Time) float32 { func Linear(t0, t1, t Time) float32 {
if t0 == t1 { if t >= t1 {
return 1 return 1
} }
if t <= t0 {
return 0
}
return float32(t-t0) / float32(t1-t0) return float32(t-t0) / float32(t1-t0)
} }