Create a gist now

Instantly share code, notes, and snippets.

@ttdoda /byonbyon.rb
Last active Apr 26, 2017

What would you like to do?
端末のウィンドウが勝手にびよんびよんなってたのしいやつ
#!/usr/bin/env ruby
# License: CC0
include Math
STDOUT.sync = 1
case `env LC_ALL=C stty -a`
when / (\d+) rows; (\d+) columns/
rows = $1.to_i
cols = $2.to_i
when /rows (?:= )?(\d+); columns (?:= )?(\d+)/
rows = $1.to_i
cols = $2.to_i
else
STDERR.puts "Can't get stty result"
exit 1
end
def resize_term(rows, cols)
print "\e[8;#{rows};#{cols}t"
end
i = 0
s = 10
trap(:INT) {
resize_term(rows, cols)
exit 0
}
while true
r = rows + (cos(PI*(i*s)/180) * 10).to_i
c = cols + (sin(PI*(i*s)/180) * 10).to_i
resize_term(r, c)
i += 1
sleep 0.05
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment