Skip to content

Commit

Permalink
Added a program icon. Changed the window title to Mandelbrot by Jort …
Browse files Browse the repository at this point in the history
…+ the version. Release of v1.5
  • Loading branch information
Jort van Waes committed Sep 20, 2023
1 parent 00a7bb7 commit 5d8b35d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Binary file added icons/rust.ico
Binary file not shown.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ static COLORING_FUNCTION: ColoringFunction = TrueColor::new_from_bernstein_polyn
//Color channel mapping
static COLOR_CHANNEL_MAPPING: ColorChannelMapping = ColorChannelMapping::RGB;

//Window title
static WINDOW_TITLE: &str = "Mandelbrot by Jort";

//Banner values
static VERSION: &str = "1.5";

//Views
static VIEW_1: View = View::new(-0.6604166666666667, 0.4437500000000001, 0.1);
static VIEW_2: View = View::new(-1.0591666666666668, 0.2629166666666668, 0.01);
Expand All @@ -63,9 +69,6 @@ static VIEW_8: View = View::new(-1.7862581627050718, 0.00005198056959995248, 0.0
static VIEW_9: View = View::new(-0.4687339999999999, 0.5425518958333333, 0.000010000000000000003);
static VIEW_0: View = View::new(-0.437520465811966, 0.5632133750000006, 0.000004000000000000004);

//Banner values
static VERSION: &str = "1.4";

///Holds all the logic currently in the main function that isn't involved with setting up configuration or handling errors, to make `main` concise and
///easy to verify by inspection
/// # Panics
Expand Down
26 changes: 21 additions & 5 deletions src/view/minifb_mandelbrot_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use minifb::{Key, Window, WindowOptions};
use std::str::FromStr;

Check warning on line 1 in src/view/minifb_mandelbrot_view.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `std::str::FromStr`

warning: unused import: `std::str::FromStr` --> src/view/minifb_mandelbrot_view.rs:1:5 | 1 | use std::str::FromStr; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default

use crate::model::mandelbrot_model::MandelbrotModel;
use minifb::{Icon, Key, Window, WindowOptions};

Check warning on line 3 in src/view/minifb_mandelbrot_view.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `Icon`

warning: unused import: `Icon` --> src/view/minifb_mandelbrot_view.rs:3:14 | 3 | use minifb::{Icon, Key, Window, WindowOptions}; | ^^^^

use crate::{model::mandelbrot_model::MandelbrotModel, VERSION, WINDOW_TITLE};

pub struct MandelbrotView {
pub window: Window,
Expand All @@ -9,15 +11,29 @@ pub struct MandelbrotView {
impl MandelbrotView {
pub fn new(mandelbrot_model: &MandelbrotModel) -> MandelbrotView {

Check warning on line 12 in src/view/minifb_mandelbrot_view.rs

View workflow job for this annotation

GitHub Actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section --> src/view/minifb_mandelbrot_view.rs:12:5 | 12 | pub fn new(mandelbrot_model: &MandelbrotModel) -> MandelbrotView { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here --> src/view/minifb_mandelbrot_view.rs:30:13 | 30 | panic!("{}", e); | ^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
// Create a new window
let window = Window::new(
"Mandelbrot set viewer",
let mut window = Window::new(
&format!("{} v{}", WINDOW_TITLE, VERSION),
mandelbrot_model.config.window_width,
mandelbrot_model.config.window_height,
WindowOptions::default(),
WindowOptions {
borderless: false,
title: true,
resize: true,
scale: minifb::Scale::X1,
scale_mode: minifb::ScaleMode::Center,
topmost: false,
transparency: false,
none: false,
},
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
//Set window background color to darkgray
window.set_background_color(27, 27, 27);

#[cfg(target_os = "windows")]
window.set_icon(Icon::from_str("icons/rust.ico").unwrap());

//Print info about the MandelbrotModel
mandelbrot_model.p.pixel_plane.print();
Expand Down

0 comments on commit 5d8b35d

Please sign in to comment.