Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better title help #2

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ fn render_mouse_rect(buffer: &mut Vec<u32>, width: usize, rect: &Rect) {
}
}

fn title_string(iterations: usize) -> String {
format!("Mandelbrot - ESC: EXIT - I/D: ITERATIONS={} - Arrows: MOVEMENT - +/-: ZOOM - R: Reset", iterations)
}

fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let options: WindowOptions = WindowOptions {
Expand All @@ -92,7 +96,7 @@ fn main() {
none: false,
};
let mut window = Window::new(
"Mandelbrot - ESC: EXIT - I/D: ITERATIONS=100 - Arrows: MOVEMENT - +/-: ZOOM - R: Reset",
&title_string(100),
WIDTH,
HEIGHT,
options,
Expand Down Expand Up @@ -222,8 +226,7 @@ fn main() {
if iterations < usize::MAX - increase {
iterations += increase;
}
let title = format!("Mandelbrot - ESC: EXIT- I/D: ITERATIONS={iterations} - Arrows: MOVEMENT - +/-: ZOOM");
window.set_title(&title);
window.set_title(&title_string(iterations));
dirty = true;
}
if window.is_key_down(Key::D) {
Expand All @@ -234,8 +237,7 @@ fn main() {
if iterations > decrease {
iterations -= decrease;
}
let title = format!("Mandelbrot - ESC: EXIT- I/D: ITERATIONS={iterations} - Arrows: MOVEMENT - +/-: ZOOM");
window.set_title(&title);
window.set_title(&title_string(iterations));
dirty = true;
}
if window.is_key_down(Key::NumPadPlus) {
Expand Down
Loading