Skip to content

Instantly share code, notes, and snippets.

@obelisk68
obelisk68 / turtle_knuth_curve.rb
Created February 6, 2018 03:32
クヌース曲線
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)
@obelisk68
obelisk68 / turtle_grate_curve.rb
Last active February 6, 2018 03:46
格子曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 400, 400
Oekaki.app width: Width, height: Height, title: "Grate curve" do
draw do
clear(color(0xffff, 0x7dff, 0))
t = Turtle.new(Width, Height, self)
@obelisk68
obelisk68 / turtle.rb
Created February 5, 2018 18:32
タートルグラフィックス
class Turtle
def initialize(width, height, ob)
@width, @height = width, height
@pen_po = Vector[0, 0]
@pen = ob
@dir = Vector[1, 0]
@color = [65535, 65535, 65535]
end
attr_accessor :pen_po, :dir
@obelisk68
obelisk68 / turtle_dragon_curve.rb
Created February 5, 2018 18:03
ドラゴン曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 450
Oekaki.app width: Width, height: Height, title: "Dragon curve" do
draw do
clear
depth = 12
@obelisk68
obelisk68 / turtle_hilbert_curve.rb
Created February 5, 2018 18:01
ヒルベルト曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 600
Oekaki.app width: Width, height: Height, title: "Hilbert curve" do
draw do
clear
depth = 5
@obelisk68
obelisk68 / turtle_koch_curve.rb
Created February 5, 2018 18:00
コッホ曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 600
Oekaki.app width: Width, height: Height, title: "Koch curve" do
draw do
clear
l = 500
@obelisk68
obelisk68 / turtle_sierpinski_curve.rb
Last active February 5, 2018 18:10
シェルピンスキー曲線
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 600
Oekaki.app width: Width, height: Height, title: "Sierpinski curve" do
draw do
clear
depth = 5
require 'oekaki'
require_relative 'turtle'
Width, Height = 600, 400
Oekaki.app width: Width, height: Height, title: "C curve" do
draw do
clear
t = Turtle.new(Width, Height, self)
@obelisk68
obelisk68 / a6.rb
Created January 23, 2018 14:07
Chipmunk
require 'bundler/setup'
require 'gosu'
require 'rmagick'
require 'chipmunk'
CV = CP::Vec2
Width, Height = 300, 300
Wall_h = 50
@obelisk68
obelisk68 / sierpinski_gasket.rb
Created January 18, 2018 09:02
シェルピンスキーのギャスケット
require 'oekaki'
Width, Height = 500, 450
Oekaki.app width: Width, height: Height, title: "Sierpinski gasket" do
draw do
clear
x1, y1 = Width / 2, Height - Width * 0.5 * Math.sqrt(3)
x2, y2 = 0, Height