Merge pull request #33 from lctrt/feat/clamp

add clamp and step function
This commit is contained in:
Лu Лinveгa 2019-07-14 09:12:40 +12:00 committed by GitHub
commit 97861dc3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,4 +163,12 @@ function Library (ronin) {
this.mod = function (a, b) {
return a % b
}
this.clamp = function (val, min, max) {
return Math.min(max, Math.max(min, val))
}
this.step = function (val, step) {
return Math.round(val / step) * step
}
}