fractal-gen

Crates.iofractal-gen
lib.rsfractal-gen
version0.1.5
sourcesrc
created_at2020-04-01 13:07:35.321792
updated_at2020-04-02 17:42:10.826198
descriptionFractals is a Rust project to generate fractals.
homepage
repositoryhttps://github.com/rust-lang/cargo/
max_upload_size
id225186
size455,450
Ibrahim Berat Kaya (iberatkaya)

documentation

README

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.

Commit count: 19121

cargo fmt