mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 19:31:30 +11:00
rustfmt
This commit is contained in:
parent
8d8c8a56db
commit
38fa50a4ef
|
@ -1,6 +1,6 @@
|
||||||
extern crate minifb;
|
extern crate minifb;
|
||||||
|
|
||||||
use minifb::{Window, Key, WindowOptions};
|
use minifb::{Key, Window, WindowOptions};
|
||||||
|
|
||||||
const WIDTH: usize = 600;
|
const WIDTH: usize = 600;
|
||||||
const HEIGHT: usize = 600;
|
const HEIGHT: usize = 600;
|
||||||
|
@ -10,7 +10,12 @@ const GENERATION_INFINITY: f64 = 16.;
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
|
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
|
||||||
|
|
||||||
let mut window = match Window::new("Fractal - ESC to exit", WIDTH, HEIGHT, WindowOptions::default()) {
|
let mut window = match Window::new(
|
||||||
|
"Fractal - ESC to exit",
|
||||||
|
WIDTH,
|
||||||
|
HEIGHT,
|
||||||
|
WindowOptions::default(),
|
||||||
|
) {
|
||||||
Ok(win) => win,
|
Ok(win) => win,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("Unable to create window {}", err);
|
println!("Unable to create window {}", err);
|
||||||
|
@ -28,12 +33,10 @@ fn main() {
|
||||||
let mut angle: f64 = 0.0;
|
let mut angle: f64 = 0.0;
|
||||||
|
|
||||||
while window.is_open() && !window.is_key_down(Key::Escape) {
|
while window.is_open() && !window.is_key_down(Key::Escape) {
|
||||||
|
|
||||||
for i in 0..buffer.len() {
|
for i in 0..buffer.len() {
|
||||||
let mut real = map((i % WIDTH) as f64, 0., WIDTH as f64, x_min, x_max);
|
let mut real = map((i % WIDTH) as f64, 0., WIDTH as f64, x_min, x_max);
|
||||||
let mut imag = map((i / HEIGHT) as f64, 0., HEIGHT as f64, y_min, y_max);
|
let mut imag = map((i / HEIGHT) as f64, 0., HEIGHT as f64, y_min, y_max);
|
||||||
|
|
||||||
|
|
||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
|
|
||||||
while n < FRACTAL_DEPTH {
|
while n < FRACTAL_DEPTH {
|
||||||
|
@ -59,7 +62,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn map(val: f64, start1: f64, stop1: f64, start2: f64, stop2: f64) -> f64 {
|
fn map(val: f64, start1: f64, stop1: f64, start2: f64, stop2: f64) -> f64 {
|
||||||
start2 + (stop2 - start2) * ((val - start1) / (stop1 - start1))
|
start2 + (stop2 - start2) * ((val - start1) / (stop1 - start1))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue