Compare commits
5 Commits
d7dafc3fe6
...
1125d79ca5
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 1125d79ca5 | |
Rekai Nyangadzayi Musuka | d23b47ed2c | |
Rekai Nyangadzayi Musuka | 0f7a8ef410 | |
Rekai Nyangadzayi Musuka | bbb5aff6b6 | |
Rekai Nyangadzayi Musuka | 2755d55192 |
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"vadimcn.vscode-lldb",
|
||||||
|
"serayuzgur.crates",
|
||||||
|
"tamasfe.even-better-toml",
|
||||||
|
"matklad.rust-analyzer"
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,11 +2,11 @@
|
||||||
name = "mandelbrot"
|
name = "mandelbrot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Rekai Musuka <rekai@musuka.dev>"]
|
authors = ["Rekai Musuka <rekai@musuka.dev>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "^0.5"
|
bevy = "0.5"
|
||||||
num-complex = "^0.4"
|
num-complex = "0.4"
|
||||||
rayon = "^1.5"
|
rayon = "1.5"
|
||||||
|
|
Binary file not shown.
18
src/main.rs
18
src/main.rs
|
@ -2,7 +2,6 @@ use bevy::diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::texture::{Extent3d, TextureDimension, TextureFormat};
|
use bevy::render::texture::{Extent3d, TextureDimension, TextureFormat};
|
||||||
use mandelbrot::{Bounds, Mandelbrot, TEXTURE_HEIGHT, TEXTURE_WIDTH};
|
use mandelbrot::{Bounds, Mandelbrot, TEXTURE_HEIGHT, TEXTURE_WIDTH};
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
const MAX_ITERATION_COUNT: u32 = 1024;
|
const MAX_ITERATION_COUNT: u32 = 1024;
|
||||||
|
|
||||||
|
@ -129,13 +128,13 @@ fn mandelbrot_render_system(
|
||||||
if let Some(material) = materials.get(handle) {
|
if let Some(material) = materials.get(handle) {
|
||||||
if let Some(texture_handle) = &material.texture {
|
if let Some(texture_handle) = &material.texture {
|
||||||
if let Some(texture) = textures.get_mut(texture_handle) {
|
if let Some(texture) = textures.get_mut(texture_handle) {
|
||||||
let z = scale.zoom;
|
let zoom = scale.zoom;
|
||||||
let h = scale.horizontal;
|
let horiz = scale.horizontal;
|
||||||
let v = scale.vertical;
|
let vert = scale.vertical;
|
||||||
let limit = scale.iteration_limit;
|
let limit = scale.iteration_limit;
|
||||||
|
|
||||||
let x = ((-2.5 * z) + h, (1.0 * z) + h);
|
let x = ((-2.5 * zoom) + horiz, (1.0 * zoom) + horiz);
|
||||||
let y = ((-1.0 * z) - v, (1.0 * z) - v);
|
let y = ((-1.0 * zoom) - vert, (1.0 * zoom) - vert);
|
||||||
let bounds = Bounds::new(x, y);
|
let bounds = Bounds::new(x, y);
|
||||||
|
|
||||||
texture
|
texture
|
||||||
|
@ -188,7 +187,6 @@ fn setup(
|
||||||
font_size: 40.0,
|
font_size: 40.0,
|
||||||
color: white,
|
color: white,
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
TextSection {
|
TextSection {
|
||||||
value: "".to_string(),
|
value: "".to_string(),
|
||||||
|
@ -197,7 +195,6 @@ fn setup(
|
||||||
font_size: 40.0,
|
font_size: 40.0,
|
||||||
color: white,
|
color: white,
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
TextSection {
|
TextSection {
|
||||||
value: "\nFrametime: ".to_string(),
|
value: "\nFrametime: ".to_string(),
|
||||||
|
@ -206,7 +203,6 @@ fn setup(
|
||||||
font_size: 40.0,
|
font_size: 40.0,
|
||||||
color: white,
|
color: white,
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
TextSection {
|
TextSection {
|
||||||
value: "".to_string(),
|
value: "".to_string(),
|
||||||
|
@ -215,16 +211,14 @@ fn setup(
|
||||||
font_size: 40.0,
|
font_size: 40.0,
|
||||||
color: white,
|
color: white,
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
TextSection {
|
TextSection {
|
||||||
value: "ms".to_string(),
|
value: "ms".to_string(),
|
||||||
style: TextStyle {
|
style: TextStyle {
|
||||||
font: ui_font.clone(),
|
font: ui_font,
|
||||||
font_size: 40.0,
|
font_size: 40.0,
|
||||||
color: white,
|
color: white,
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -92,6 +92,7 @@ impl Mandelbrot {
|
||||||
self.frame_buffer.as_ref()
|
self.frame_buffer.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn olc_colours(iters: f64) -> [u8; 4] {
|
fn olc_colours(iters: f64) -> [u8; 4] {
|
||||||
let a = 0.1;
|
let a = 0.1;
|
||||||
|
|
||||||
|
@ -122,6 +123,7 @@ impl Mandelbrot {
|
||||||
Self::count_iterations(c, limit)
|
Self::count_iterations(c, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::many_single_char_names)]
|
||||||
fn hsv_to_rgb(h: f64, s: f64, v: f64) -> [u8; 4] {
|
fn hsv_to_rgb(h: f64, s: f64, v: f64) -> [u8; 4] {
|
||||||
let c = v * s;
|
let c = v * s;
|
||||||
let x = c * (1.0 - (((h / 60.0) % 2.0) - 1.0).abs());
|
let x = c * (1.0 - (((h / 60.0) % 2.0) - 1.0).abs());
|
||||||
|
|
Loading…
Reference in New Issue