Methods

Fractals::Renderers::RMagickRenderer

Renders fractals using the RMagick library.

Public Instance Methods

to_blob(file_format) click to toggle source

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’)

# File lib/fractals/renderers.rb, line 149
      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
write(file_path='fractal.png') click to toggle source

Writes the image to the specified file path.

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.