Skip to content

Commit 2724c3f

Browse files
authored
Merge pull request #33 from kojix2/kojix2-patch-1
Fix animation example
2 parents 43a7be5 + d0facc3 commit 2724c3f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

example/animation.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def out.tty?; true; end
1212
Signal.trap(:INT) { continue = false }
1313

1414
while continue
15-
out.rewind
15+
out.truncate(0)
1616

1717
xs = 0...N
1818
ys = xs.map {|x| Math.sin(2*Math::PI*(x + shift) / N) }
@@ -22,13 +22,16 @@ def out.tty?; true; end
2222
lines.each do |line|
2323
$stdout.print "\r#{line}"
2424
end
25+
$stdout.print "\e[0J"
2526
$stdout.flush
2627

28+
sleep 0.2
29+
2730
if continue
2831
n = lines.count
2932
$stdout.print "\e[#{n}F"
3033
shift = (shift + M) % N
3134
end
32-
33-
sleep 0.2
3435
end
36+
37+
$stdout.print "\e[0J"

0 commit comments

Comments
 (0)