Ruby Fractal Library
The Ruby Fractal Library is a library for creating fractal images in your Ruby programs. It currently renders both the Mandelbrot and Julia set fractals using the Escape Time or Normalized Iteration Count algorithms. The Themes module contains a couple of predefined coloring palettes, but the Fractal type will also accept any user-defined algorithms or themes.
If you’re a Python programmer you should also check out Edd Arrdvark’s excellent Mandelbrot and Julia set fractal generator. I hope that one day the Ruby Fractal Library will have as much depth for creating fractals!
Just as version 1.0.0, creating a fractal is as easy as:
mandelbrot = Mandelbrot.new
mandelbrot.drawUsing the new features allows more flexibility. The example below shows a Julia set fractal rendered using the Normalized Iteration Count algorithm and a user-defined color theme. Width, height, magnification, and set color have also been given public properties.
snowflakes = Julia.new(Complex(-0.3007, 0.6601), 5, 100)
snowflakes.width = 350
snowflakes.height = 350
snowflakes.m = 2
snowflakes.set_color = PNG::Color::White
snowflakes.algorithm = Algorithms::NormalizedIterationCount
snowflakes.theme = lambda { |index|
r, g, b = 0, 0, 0
if index >= 510
r = 0
g = 255 % index
b = 255
elsif index >= 255
r = 0
g = index % 255
b = 255
else
b = index % 255
end
return r, g, b
}
snowflakes.draw('snowflakes.png')Executing this code produces an image that looks like a snowflake.

You can check out the latest SVN revision by issuing the following command:
svn checkout http://svn.ryanbaxter.net/fractals/trunk fractalsOr get major releases.
svn checkout http://svn.ryanbaxter.net/fractals/tags/release-1.1.0 fractals-1.1.0Major releases can also be downloaded using the links below:

