Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Created February 6, 2018 03:32
Show Gist options
  • Save obelisk68/278e8b355d04c9ac108434903f284b41 to your computer and use it in GitHub Desktop.
Save obelisk68/278e8b355d04c9ac108434903f284b41 to your computer and use it in GitHub Desktop.
クヌース曲線
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