#分形 #图像 #图案 #分形 #生成器 #形状

fractal-gen

分形生成器是一个用于生成分形的Rust项目

5个版本

0.1.5 2020年4月2日
0.1.4 2020年4月2日

#484 in 图像

每月37次下载

MIT许可证

380KB
596

分形生成器

Crate API

分形生成器是一个Rust项目,用于生成分形。

分形是一个Crate,它生成图像作为分形,没有任何外部依赖。图像以BMP文件保存。查看日志文档

一些分形

  • 曼德布罗特集
  • 朱利亚集
  • 科赫曲线
  • 谢尔宾斯基三角形
  • 巴恩斯利蕨

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");
}

作者

👤 Ibrahim Berat Kaya

🤝 贡献

欢迎贡献、问题和特性请求!
请随意查看问题页面

没有运行时依赖