5 releases

0.1.5 Apr 2, 2020
0.1.4 Apr 2, 2020

#449 in Images

MIT license

380KB
596 lines

Fractal Gen

Crate API

Fractal Gen is a Rust project to generate fractals.

Fractals is a Crate that generate fractals as images without any external dependencies. The images are saved as a BMP files. Checkout the log and documentation.

Some Fractals:

  • Mandelbrot Set
  • Julia Set
  • Koch Curve
  • Sierpinski Triangle
  • Barnsley Fern
  • Tree

Logo

extern crate fractal_gen;
use fractal_gen::{image::pixel::Pixel, fractal::Fractal};


fn main() {
    // The pixel array
    let mut pixels = vec![];    

    // Height = 1000px
    for _i in 0..1000 {
        let mut row = vec![];
        // Width = 1000px
        for _j in 0..1000 {
            row.push(Pixel::new(255, 255, 255));
        }
        pixels.push(row);
    }
    // Create a Fractal from the pixels.
    let mut image = Fractal::new(pixels);

    // Draw the Mandelbrot Set on the image.
    image.mandelbrot(Pixel::new(250, 0, 0));

    // Draw a Sierpinksi Triangle on the image.
    image.sierpinski_triangle(180, 180, 100, Pixel::new(0, 0, 250));
    
    // Draw a Koch Curve on the image.
    image.koch_curve(675, 75, 925, 325, 5, Pixel::new(0, 250, 0));

    // Write the BMP image.
    image.write_image("./test.bmp");
}

Author

👤 Ibrahim Berat Kaya

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check the issues page.

No runtime deps