Created
February 6, 2018 03:32
-
-
Save obelisk68/278e8b355d04c9ac108434903f284b41 to your computer and use it in GitHub Desktop.
クヌース曲線
This file contains hidden or 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' | |
require_relative 'turtle' | |
Width, Height = 600, 350 | |
Oekaki.app width: Width, height: Height, title: "Knuth curve" do | |
draw do | |
clear | |
t = Turtle.new(Width, Height, self) | |
t.color(0xf0ff, 0xffff, 0xffff) | |
t.move(250, -100) | |
t.left(180) | |
step = 8 | |
drawing = lambda do |depth, a, tn| | |
if depth.zero? | |
t.right(45 + tn) | |
t.forward(step) | |
t.left(45 + tn) | |
else | |
t.right(2 * tn + a) | |
drawing[depth - 1, 2 * tn, -tn] | |
t.right(45 - 3 * tn - a) | |
t.forward(step) | |
t.left(45 - tn + a) | |
drawing[depth - 1, 0, -tn] | |
t.right(a) | |
end | |
end | |
drawing[9, -90, 45] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment