前回のエントリで作った Turtle クラスを Gem 'oekaki' に同梱しました。これでバージョンは 0.1.5 になります。
oekaki | RubyGems.org | your community gem host
GTK+でお絵かきしてみた(Ruby) - Camera Obscura
使い方はほぼ同じです。インスタンスの生成に
t = Turtle.new(width, height, self)
だったのが、
t = Oekaki::Turtle.new
になるだけです。引数はまったく要りません。
例。
require 'oekaki' Oekaki.app width: 600, height: 400, title: "C curve" do draw do clear t = Oekaki::Turtle.new t.move(-130, -100) t.color(0, 65535, 0) ratio = sqrt(2) / 2 drawing = lambda do |length, depth| if depth.zero? t.forward(length) else t.left(45) drawing[length * ratio, depth - 1] t.right(90) drawing[length * ratio, depth - 1] t.left(45) end end drawing[260.0, 10] end end