diff --git a/Cargo.toml b/Cargo.toml index 34b86e0..fa06f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -eframe = { version = "0.22.0", default-features = false, features = ["glow", "default_fonts"] } +eframe = { version = "0.22.0", default-features = false, features = [ + "glow", + "default_fonts", +] } image = { version = "0.24.6", default-features = false, features = ["png"] } native-dialog = "0.6.4" rand = "0.8.5" diff --git a/src/generate.rs b/src/generate.rs index 6c632ae..616e786 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -13,8 +13,6 @@ pub struct RenderOptions { pub cx: f64, pub cy: f64, pub fill_style: FillStyle, - #[serde(default)] - pub invert: bool, } #[derive(Clone, PartialEq, Serialize, Deserialize)] @@ -33,7 +31,6 @@ impl Default for RenderOptions { cx: 0.4, cy: -0.2, fill_style: FillStyle::Bright, - invert: false, } } } @@ -61,18 +58,13 @@ pub fn render_c(q: &RenderOptions, mut image: RgbImage) -> RgbImage { image } -pub fn color_iteration(iter: u16, color: (u8, u8, u8), invert: bool) -> Rgb { +pub fn color_iteration(iter: u16, color: (u8, u8, u8)) -> Rgb { let i = iter.min(255) as u8; - let (r, g, b) = ( + Rgb([ i.saturating_mul(color.0), i.saturating_mul(color.1), i.saturating_mul(color.2), - ); - if invert { - Rgb([255 - r, 255 - g, 255 - b]) - } else { - Rgb([r, g, b]) - } + ]) } pub fn render_julia(q: &RenderOptions, color: (u8, u8, u8)) -> RgbImage { @@ -83,8 +75,8 @@ pub fn render_julia(q: &RenderOptions, color: (u8, u8, u8)) -> RgbImage { let ppu = width / q.unit_width; let fill = match q.fill_style { - FillStyle::Black => Rgb([q.invert as u8 * 255; 3]), - FillStyle::Bright => color_iteration(q.max_iter, color, q.invert), + FillStyle::Black => Rgb([0; 3]), + FillStyle::Bright => color_iteration(q.max_iter, color), }; (0..q.height) @@ -99,7 +91,7 @@ pub fn render_julia(q: &RenderOptions, color: (u8, u8, u8)) -> RgbImage { if i == q.max_iter { row.push(fill); } else { - row.push(color_iteration(i, color, q.invert)); + row.push(color_iteration(i, color)); } } row diff --git a/src/main.rs b/src/main.rs index 24709fa..3039ff4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -250,7 +250,6 @@ impl eframe::App for JuliaGUI { .radio_value(&mut self.settings.fill_style, FillStyle::Bright, "Bright") .changed(); }); - let set_invert = ui.checkbox(&mut self.settings.invert, "invert"); ui.horizontal(|ui| { ui.label("Colour (RGB)"); @@ -390,7 +389,6 @@ impl eframe::App for JuliaGUI { || set_red.changed() || set_green.changed() || set_blue.changed() || set_point_vis.changed() - || set_invert.changed() { self.settings_changed = true; }