mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 23:17:25 +01:00
16 lines
No EOL
231 B
Text
16 lines
No EOL
231 B
Text
enum MOD_NEG {
|
|
_default,
|
|
wrap
|
|
}
|
|
|
|
function safe_mod(numb, modd, _neg = MOD_NEG._default) {
|
|
INLINE
|
|
|
|
var _md = modd == 0? 0 : numb % modd;
|
|
if(_md < 0)
|
|
switch(_neg) {
|
|
case MOD_NEG.wrap : _md += modd; break;
|
|
}
|
|
|
|
return _md;
|
|
} |