Skip to content

Instantly share code, notes, and snippets.

@tyru
Forked from ohac/aawave.rb
Created April 16, 2010 11:37
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 tyru/368331 to your computer and use it in GitHub Desktop.
Save tyru/368331 to your computer and use it in GitHub Desktop.
wave
# -*- 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