Created
February 17, 2018 13:24
-
-
Save obelisk68/6cbc9ed9df538ca46b55648a60a3fb22 to your computer and use it in GitHub Desktop.
再帰曲線(ゴシック・フリーズ)描画のアニメーション版
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 '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