Crates.io | fractal-gen |
lib.rs | fractal-gen |
version | 0.1.5 |
source | src |
created_at | 2020-04-01 13:07:35.321792 |
updated_at | 2020-04-02 17:42:10.826198 |
description | Fractals is a Rust project to generate fractals. |
homepage | |
repository | https://github.com/rust-lang/cargo/ |
max_upload_size | |
id | 225186 |
size | 455,450 |
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.
Mandelbrot Set
Julia Set
Koch Curve
Sierpinski Triangle
Barnsley Fern
Tree
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");
}
👤 Ibrahim Berat Kaya
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.