math.rep
code:Lua
y = textmodule.math.rep(x, min, max)
モジュール
引数
table:_
変数 型 概要
1 x number 処理する数値
2 min number 最小値
3 max number 最大値
返り値
table:_
変数 型 概要
1 y number 処理された数値
概要
xをmin以上max以下の範囲に抑える。
min未満の場合: max-minの値を範囲内になるまで加える
max以上の場合: max-minの値を範囲内になるまで引く
角度のような、値が増減した時にループするような値の処理に向く。
例
code:lua
require("textmodule")
r1 = textmodule.math.rep(250, 0, 360)
debug_print(r1) -- 250
r2 = textmodule.math.trunc(410, 0, 360)
debug_print(r2) -- 50
r3 = textmodule.math.trunc(-100, 0, 360)
debug_print(r3) -- 260