mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 06:56:45 +01:00
19 lines
No EOL
412 B
Text
19 lines
No EOL
412 B
Text
function string_lead_zero(val, digit) {
|
|
var len = string_length(string(val));
|
|
var zer = digit - len;
|
|
|
|
var ss = "";
|
|
repeat(zer) ss += "0";
|
|
ss += string(val);
|
|
|
|
return ss;
|
|
}
|
|
|
|
function string_byte_format(bytes) {
|
|
static suffix = [ "B", "KB", "MB", "GB", "TB" ];
|
|
|
|
var lv = clamp(floor(log2(bytes) / 10), 0, array_length(suffix) - 1);
|
|
var amo = bytes / power(2, lv * 10);
|
|
|
|
return $"{amo} {suffix[lv]}"
|
|
} |