Created
December 24, 2020 12:21
-
-
Save pavi2410/01443c77b36ce61002c2abf5bd146a04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn loading() { | |
colors := [41, 42, 43, 44, 45, 46] | |
cursor_left := '\e[1000D' | |
reset := '\e[0m' | |
pbar := ' ' | |
scale := 2 | |
for i in 0..100+1 { | |
time.sleep_ms(50) | |
width := (i+1) / scale | |
mut bar := '' | |
for w in 0..width { | |
bar += '\e[${colors[(w+i) % colors.len]}m' + pbar | |
} | |
bar += reset + ' '.repeat((100 - i) / scale) + ' | $i%' | |
print(cursor_left + bar) | |
os.flush() | |
} | |
println('') | |
} | |
fn loading2() { | |
for i in 0..100+1 { | |
time.sleep_ms(50) | |
width := (i + 1) / 4 | |
bar := '\e[42m '.repeat(width) + '\e[0m' + ' '.repeat(25 - width) + '| $i%' | |
print('\e[1000D$bar') | |
os.flush() | |
} | |
println('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment