5个版本
0.1.5 | 2020年4月2日 |
---|---|
0.1.4 |
|
#484 in 图像
每月37次下载
380KB
596 行
分形生成器
分形生成器是一个Rust项目,用于生成分形。
分形是一个Crate,它生成图像作为分形,没有任何外部依赖。图像以BMP文件保存。查看日志和文档。
一些分形
- 曼德布罗特集
- 朱利亚集
- 科赫曲线
- 谢尔宾斯基三角形
- 巴恩斯利蕨
- 树
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
- Github: @iberatkaya
- LinkedIn: @linkedin.com/in/ibrahim-berat-kaya/
🤝 贡献
欢迎贡献、问题和特性请求!
请随意查看问题页面。