-
-
Save tyru/368331 to your computer and use it in GitHub Desktop.
wave
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
# -*- coding: utf-8 -*- | |
require 'curses' | |
def val2aa(wave, val) | |
wave[(val + 0x8000) * wave.size / 0x10000] | |
end | |
def write_wave(counter) | |
[ | |
# ['˾_˼ߎ˨-˧H˕ߙ˦˥՟T˺˭'.split(//u), 79], # 文字化けする... | |
['.+^+.+^+.'.split(//u), 79], | |
].each do |pr| | |
12.times do |y| | |
# Curses::setpos(y - 1) | |
str = pr[1].times.map{|x|val2aa(pr[0],0x7fff*Math.sin(x+counter/3.0+y))}.join | |
Curses::addstr str + "\n" | |
end | |
end | |
end | |
def do_loop() | |
Curses::init_screen | |
(1..12).each {|i| | |
Curses::clear | |
write_wave i | |
Curses::refresh | |
sleep 0.5 | |
} | |
Curses::close_screen | |
end | |
do_loop | |
=begin | |
$ ruby aawave.rb | |
+.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........+ | |
.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++ | |
++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++. | |
+........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^ | |
........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+ | |
.......++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+. | |
......++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^ | |
.....++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^ | |
....++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^. | |
...++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+ | |
..++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^ | |
.++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^.++........++.^+.^^.+^. | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment