Last active
December 12, 2018 18:14
-
-
Save obelisk68/a6268d2d55b17ebd9ef42bbb6020b86d to your computer and use it in GitHub Desktop.
ANSIエスケープシーケンスで遊ぶ
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
require_relative 'es' | |
L = 14 #一辺の長さ(偶数にする) | |
print ES.safe_scroll(L) | |
i = 0 | |
x, y = ES.cursor_position | |
x -= 1 | |
square = ->(width) { | |
return if width < 1 | |
line = ->(dx, dy, ln) { | |
ln.times do | |
x += dx | |
y += dy | |
print ES.cursor(x * 2 - 1, y) + ES.color(:code, i % 7 + 91) + "#" #"#"は全角 | |
i += 1 | |
sleep(0.1) | |
end | |
} | |
line.( 1, 0, width) | |
line.( 0, 1, width - 1) | |
line.(-1, 0, width - 1) | |
line.( 0, -1, width - 2) | |
square.(width - 2) | |
} | |
square.(L) | |
print ES.top + ES.cursor_r(0, L / 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment