Module Fractals::Renderers::RMagickRenderer
In: lib/fractals/renderers.rb

Renders fractals using the RMagick library.

Methods

to_blob   write  

Public Instance methods

Returns the fractal image as a BLOB of the specified file format.

Example:

mandelbrot = Mandelbrot.new
mandelbrot.renderer = Renderers::RMagickRenderer
blob = mandelbrot.to_blob(‘jpg’)

[Source]

# File lib/fractals/renderers.rb, line 129
      def to_blob(file_format)
        image = Magick::Image.new(@width, @height)
        render do |x, y, color|
          image.pixel_color(x, y, "rgb(#{color.join(',')})")
        end

        image.to_blob { self.format = file_format; self.quality = 100 }
      end

Writes the image to the specified file path.

[Source]

# File lib/fractals/renderers.rb, line 139
      def write(file_path='fractal.png')
        File.open(file_path, 'wb') do |file|
          file.write(to_blob(file_path.split('.').last))
        end
      end

[Validate]