Skip to content

Instantly share code, notes, and snippets.

@obelisk68 obelisk68/es_sample1.rb
Last active Dec 12, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.