Edited at

# 樹木曲線

More than 1 year has passed since last update.

ちょっとしたフラクタル

# 描写

```require "rmagick"

def draw(i, from, len, rad, r, depth)
to = [
]

d = Magick::Draw.new
d.stroke("green")
d.line(from[1],from[0],to[1],to[0])
d.draw(i)

#p [from, to, depth]

if depth > 0
draw(i, to, len * 0.7, rad + r, r, depth - 1)
draw(i, to, len * 0.7, rad - r, r, depth - 1)
end
end

il = Magick::ImageList.new
i = il.new_image(500,500)
i.annotate(Magick::Draw.new, 1, 1, 30, 30, n.to_s)
draw(i, [250,250], 50, Math::PI/-2, 0.5, 10)
i.write("tree1.gif")
```

# さらに描写

```il = Magick::ImageList.new
il.delay = 50
for n in 1 .. 40
i = il.new_image(500,500)
i.annotate(Magick::Draw.new, 1, 1, 30, 30, n.to_s)
draw(i, [250,250], 50, Math::PI/-2, Math::PI/10*(0.1*n), 10)
end
i.write("tree2.gif")
```

# もっと描写

```def draw(i, from, len, rad, r, depth)
to = [
]

d = Magick::Draw.new
d.stroke("green")
d.line(from[1],from[0],to[1],to[0])
d.draw(i)

#p [from, to, depth]

if depth > 0
draw(i, to, len * 0.7, rad * r, r, depth - 1)
draw(i, to, len * 0.7, rad - r, r, depth - 1)
end
end

il = Magick::ImageList.new
il.delay = 50
for n in 1 .. 60
i = il.new_image(500,500)
i.annotate(Magick::Draw.new, 1, 1, 30, 30, n.to_s)
draw(i, [250,250], 50, Math::PI/-2, Math::PI/10*(0.1*n), 10)
end
i.write("tree3.gif")
```

# せわしない描写

```def draw(i, from, len, rad, r, depth)
to = [
]

d = Magick::Draw.new
d.stroke("green")
d.line(from[1],from[0],to[1],to[0])
d.draw(i)

#p [from, to, depth]

if depth > 0
draw(i, to, len * 0.7, rad + r, r, depth - 1)
draw(i, to, len * 0.7, rad + r*2, r, depth - 1)
end
end

il = Magick::ImageList.new
il.delay = 50
for n in 1 .. 100
i = il.new_image(500,500)
i.annotate(Magick::Draw.new, 1, 1, 30, 30, n.to_s)
draw(i, [250,250], 50, Math::PI/-2, 0.1*n, 10)
end
i.write("tree4.gif")
```