Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Last active December 12, 2018 18:14
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 obelisk68/a6268d2d55b17ebd9ef42bbb6020b86d to your computer and use it in GitHub Desktop.
Save obelisk68/a6268d2d55b17ebd9ef42bbb6020b86d to your computer and use it in GitHub Desktop.
ANSIエスケープシーケンスで遊ぶ
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