mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-16 07:23:52 +01:00
16 lines
231 B
Plaintext
16 lines
231 B
Plaintext
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;
|
|
} |