Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Created February 5, 2018 18:03
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/f87eb7552f2885277f63c5a84920716e to your computer and use it in GitHub Desktop.
Save obelisk68/f87eb7552f2885277f63c5a84920716e to your computer and use it in GitHub Desktop.
ドラゴン曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 450
Oekaki.app width: Width, height: Height, title: "Dragon curve" do
draw do
clear
depth = 12
l = 350
t = Turtle.new(Width, Height, self)
t.color(0xf0ff, 0xffff, 0xffff)
t.move(-l / 2, 50)
drawing = lambda do |length, depth|
if depth.zero?
t.forward(length)
else
len = length / sqrt(2)
po1 = t.pen_po
t.forward(length, false)
po2, t.pen_po = t.pen_po, po1
t.right(45)
drawing[len, depth - 1]
t.pen_po = po2
t.right(90)
drawing[len, depth - 1]
t.pen_po = po2
t.left(135)
end
end
drawing[l, depth]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment