Ruby Fractal Library
Fractals is a library for creating fractal images in your Ruby programs. It currently renders the Burning Ship, Julia Set, Mandelbrot, and Newton fractals using the Escape Time or Normalized Iteration Count algorithm. The Themes module contains a few predefined coloring palettes, but the Fractal type will
also accept any user-defined algorithm or theme.
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.writeUsing the new features allows more flexibility. In the example below, I’m creating an animated fractal using RMagick and the RMagickRenderer’s to_blob method. This is both CPU and memory intensive so act accordingly. This is about as complicated as it gets.
feigenbaum = Mandelbrot.new(Complex(-0.1528, 1.0397))
feigenbaum.max_iterations = 100
feigenbaum.renderer = Renderers::RMagickRenderer
feigenbaum.width = 150
feigenbaum.height = 150
feigenbaum.magnification = 25
feigenbaum.algorithm = Algorithms::NormalizedIterationCount
feigenbaum.theme = Themes::Water
image_list = Magick::ImageList.new
image_list.delay = 100
image_list.iterations = 1
(0...50).each { |i|
feigenbaum.magnification += (i**2)
image_list << Magick::Image.from_blob(feigenbaum.to_blob('gif'))[0]
}
image_list.write('feigenbaum.gif')*Be sure to install the proper dependencies before using the RMagick or JRuby renderers.
More examples can be found throughout this website and in the examples.rb file found in the project’s source. You should also take a look at the README file and documentation before getting started. With rubygems, you can install the Ruby Fractal Library by issuing the following command:
sudo gem install fractalsOr check out the latest revision from the SVN repository:
svn checkout http://svn.ryanbaxter.net/fractals/trunk fractalsMajor releases can be downloaded using the links below or by visiting the RubyForge project page. Bugs can be filed at the RubyForge tracker.
fractals-1.2.2.gem
fractals-1.2.2.tgz
fractals-1.2.2.zip

