mirror of
https://github.com/CrispyPin/julia-fractal-renderer.git
synced 2024-11-25 11:30:28 +01:00
pink
This commit is contained in:
parent
f02250a507
commit
70373c8ff7
1 changed files with 15 additions and 12 deletions
27
src/main.rs
27
src/main.rs
|
@ -2,15 +2,22 @@ use std::time::SystemTime;
|
||||||
|
|
||||||
use image::{Rgb, RgbImage};
|
use image::{Rgb, RgbImage};
|
||||||
|
|
||||||
const WIDTH: u32 = 4096;
|
const WIDTH: u32 = 1920 * 2;
|
||||||
const HEIGHT: u32 = WIDTH / 2;
|
const HEIGHT: u32 = 1080 * 2;
|
||||||
|
|
||||||
const TOTAL_UNITS_WIDE: f64 = 4.0;
|
const TOTAL_UNITS_WIDE: f64 = 4.0;
|
||||||
|
|
||||||
const MAX_ITER: u32 = 512;
|
const MAX_ITER: u32 = 512;
|
||||||
const CX: f64 = -0.98;
|
const CX: f64 = -0.981;
|
||||||
const CY: f64 = -0.277;
|
const CY: f64 = -0.277;
|
||||||
|
|
||||||
|
// const COL_R: u8 = 4;
|
||||||
|
// const COL_G: u8 = 8;
|
||||||
|
// const COL_B: u8 = 12;
|
||||||
|
const COL_R: u8 = 12;
|
||||||
|
const COL_G: u8 = 5;
|
||||||
|
const COL_B: u8 = 10;
|
||||||
|
|
||||||
const WIDTH_F: f64 = WIDTH as f64;
|
const WIDTH_F: f64 = WIDTH as f64;
|
||||||
const HEIGHT_F: f64 = HEIGHT as f64;
|
const HEIGHT_F: f64 = HEIGHT as f64;
|
||||||
const PIXELS_PER_UNIT: f64 = WIDTH_F / TOTAL_UNITS_WIDE;
|
const PIXELS_PER_UNIT: f64 = WIDTH_F / TOTAL_UNITS_WIDE;
|
||||||
|
@ -29,13 +36,9 @@ fn main() {
|
||||||
"Generating took {} ms",
|
"Generating took {} ms",
|
||||||
start_time.elapsed().unwrap().as_millis()
|
start_time.elapsed().unwrap().as_millis()
|
||||||
);
|
);
|
||||||
let start_time = SystemTime::now();
|
|
||||||
let filename = format!("julia_set_cx{:.3}_cy{:.3}.png", CX, CY);
|
let filename = format!("julia_set_cx{}_cy{}.png", CX, CY);
|
||||||
img.save(filename).unwrap();
|
img.save(filename).unwrap();
|
||||||
println!(
|
|
||||||
"Saving took {} ms",
|
|
||||||
start_time.elapsed().unwrap().as_millis()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fractal(x: f64, y: f64) -> Rgb<u8> {
|
fn fractal(x: f64, y: f64) -> Rgb<u8> {
|
||||||
|
@ -58,8 +61,8 @@ fn fractal(x: f64, y: f64) -> Rgb<u8> {
|
||||||
|
|
||||||
let i = iterations.min(255) as u8;
|
let i = iterations.min(255) as u8;
|
||||||
Rgb([
|
Rgb([
|
||||||
i.saturating_mul(4),
|
i.saturating_mul(COL_R),
|
||||||
i.saturating_mul(8),
|
i.saturating_mul(COL_G),
|
||||||
i.saturating_mul(12),
|
i.saturating_mul(COL_B),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue