Module: Fractals::Renderers::JRubyRenderer
- Defined in:
- lib/fractals/renderers.rb
Overview
Renders fractals using native Java libraries.
Instance Method Summary collapse
-
#write(file_path = 'fractal.png') ⇒ Object
Writes the image to the specified file path.
Instance Method Details
#write(file_path = 'fractal.png') ⇒ Object
Writes the image to the specified file path.
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/fractals/renderers.rb', line 151 def write(file_path='fractal.png') import java.awt.image.BufferedImage import javax.imageio.ImageIO buffered_image = BufferedImage.new(@width, @height, BufferedImage::TYPE_INT_RGB) render do |x, y, color| buffered_image.setRGB(x, y, to_rgb(color)) end ImageIO.write(buffered_image, file_path.split('.').last, java.io.File.new(file_path)) end |