Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Created February 17, 2018 13:24
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/6cbc9ed9df538ca46b55648a60a3fb22 to your computer and use it in GitHub Desktop.
Save obelisk68/6cbc9ed9df538ca46b55648a60a3fb22 to your computer and use it in GitHub Desktop.
再帰曲線(ゴシック・フリーズ)描画のアニメーション版
require 'oekaki'
Oekaki.app width: 420, height: 420, title: "Turtle" do
draw {clear}
t = Oekaki::Turtle.new
t.color(0xffff, 0x45ff, 0) #orangered
t.move(-200, -200)
t.left(45)
e = Enumerator.new do |y|
drawing = lambda do |n, l|
if n == 1
y << [t, l]
else
drawing[n - 1, l / 3]
t.left(90)
drawing[n - 1, l / 3]
t.right(90)
drawing[n - 1, l / 3]
t.right(90)
drawing[n - 1, l / 3]
t.left(90)
drawing[n - 1, l / 3]
end
end
drawing[4, 400 * sqrt(2)]
end
timer(100) do
t, l = e.next rescue next
t.forward(l)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment