Skip to content

Instantly share code, notes, and snippets.

@pavi2410
Created December 24, 2020 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavi2410/01443c77b36ce61002c2abf5bd146a04 to your computer and use it in GitHub Desktop.
Save pavi2410/01443c77b36ce61002c2abf5bd146a04 to your computer and use it in GitHub Desktop.
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