summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/benoit/benoit/application.rs10
-rw-r--r--source/benoit/benoit/application/animate.rs4
-rw-r--r--source/benoit/benoit/application/colour.rs2
-rw-r--r--source/benoit/benoit/application/draw.rs22
-rw-r--r--source/benoit/benoit/application/dump.rs4
-rw-r--r--source/benoit/benoit/application/initialise.rs9
-rw-r--r--source/benoit/benoit/application/loop.rs4
-rw-r--r--source/benoit/benoit/application/render.rs4
-rw-r--r--source/benoit/benoit/application/render_row_julia.rs7
-rw-r--r--source/benoit/benoit/application/render_row_normal.rs7
-rw-r--r--source/benoit/benoit/configuration.rs7
-rw-r--r--source/benoit/benoit/configuration/default.rs7
-rw-r--r--source/benoit/benoit/configuration/load.rs7
-rw-r--r--source/benoit/benoit/iteration/iterate_burning_ship.rs2
-rw-r--r--source/benoit/benoit/render_data.rs3
-rw-r--r--source/benoit/benoit/render_data/new.rs5
-rw-r--r--source/benoit/benoit/video/initialise.rs4
17 files changed, 54 insertions, 54 deletions
diff --git a/source/benoit/benoit/application.rs b/source/benoit/benoit/application.rs
index 574179c..b05ede2 100644
--- a/source/benoit/benoit/application.rs
+++ b/source/benoit/benoit/application.rs
@@ -48,9 +48,6 @@ pub mod run;
pub type RowRenderer = fn(Arc<RenderData>, u32, IteratorFunction);
-// We pass this struct to draw the offset feedback.
-// Currently unused, however.
-#[allow(dead_code)]
pub struct PreviousPosition {
centre_real: Float,
centre_imag: Float,
@@ -63,10 +60,9 @@ pub struct Application {
fractal: Fractal,
julia: bool,
- canvas_width: u32,
- canvas_height: u32,
- scale: u32,
- frame_count: u32,
+ canvas_width: u32,
+ scale: u32,
+ frame_count: u32,
centre_real: Float,
centre_imag: Float,
diff --git a/source/benoit/benoit/application/animate.rs b/source/benoit/benoit/application/animate.rs
index 632099d..117f430 100644
--- a/source/benoit/benoit/application/animate.rs
+++ b/source/benoit/benoit/application/animate.rs
@@ -68,7 +68,7 @@ impl Application {
eprintln!("animating {} frames at {}{:+}i to {:.3} (fac.: {:.3})", self.frame_count, self.centre_real.to_f64(), self.centre_imag.to_f64(), zoom_stop.to_f64(), zoom_factor.to_f64());
- let canvas_size = self.canvas_height as usize * self.canvas_width as usize;
+ let canvas_size = self.canvas_width as usize * self.canvas_width as usize;
let mut iter_count_buffer: Vec::<u32> = vec![0x0; canvas_size];
let mut square_dist_buffer: Vec::<f32> = vec![0.0; canvas_size];
@@ -80,7 +80,7 @@ impl Application {
self.render(&mut iter_count_buffer[..], &mut square_dist_buffer[..], &self.centre_real, &self.centre_imag, &zoom, self.max_iter_count);
self.colour(&mut image[..], &mut iter_count_buffer[..], &mut square_dist_buffer[..]);
- self.dump(format!("{}/frame{frame:010}.webp", self.dump_path), &image, self.canvas_width, self.canvas_height);
+ self.dump(format!("{}/frame{frame:010}.webp", self.dump_path), &image, self.canvas_width);
zoom.mul_assign(&zoom_factor);
}
diff --git a/source/benoit/benoit/application/colour.rs b/source/benoit/benoit/application/colour.rs
index 7139828..c243f71 100644
--- a/source/benoit/benoit/application/colour.rs
+++ b/source/benoit/benoit/application/colour.rs
@@ -25,7 +25,7 @@ use crate::benoit::application::Application;
impl Application {
pub fn colour(&self, buffer: &mut [u8], iter_count_buffer: &[u32], square_dist_buffer: &[f32]) {
- let canvas_size = self.canvas_height * self.canvas_width;
+ let canvas_size = self.canvas_width * self.canvas_width;
for pixel in 0x0..canvas_size {
let iter_count = iter_count_buffer[pixel as usize];
diff --git a/source/benoit/benoit/application/draw.rs b/source/benoit/benoit/application/draw.rs
index fdce93e..7c62c98 100644
--- a/source/benoit/benoit/application/draw.rs
+++ b/source/benoit/benoit/application/draw.rs
@@ -33,7 +33,7 @@ use sdl2::rect::Rect;
impl Application {
pub fn draw(&mut self, image: &[u8], previous_position: &PreviousPosition) {
- let canvas_size = self.canvas_height * self.canvas_width;
+ let canvas_size = self.canvas_width * self.canvas_width;
for pixel in 0x0..canvas_size {
let y = pixel as u32 / self.canvas_width;
@@ -74,11 +74,23 @@ impl Application {
let mut width = Float::with_val(PRECISION, 1.0 / &zoom_ratio);
- let mut offset_x = Float::with_val(PRECISION, 1.0 - &width);
- let mut offset_y = Float::with_val(PRECISION, 1.0 - &width);
+ let mut offset_x = self.centre_real.clone();
+ let mut offset_y = self.centre_imag.clone();
- offset_x /= 2.0;
- offset_y /= 2.0;
+ offset_x -= &previous_position.centre_real;
+ offset_y -= &previous_position.centre_imag;
+
+ offset_x /= 4.0;
+ offset_y /= 4.0;
+
+ offset_x *= &previous_position.zoom;
+ offset_y *= &previous_position.zoom;
+
+ let mut zoom_offset = Float::with_val(PRECISION, 1.0 - &width);
+ zoom_offset /= 2.0;
+
+ offset_x += &zoom_offset;
+ offset_y += &zoom_offset;
offset_x *= &canvas_width;
offset_y *= &canvas_width;
diff --git a/source/benoit/benoit/application/dump.rs b/source/benoit/benoit/application/dump.rs
index a7b2915..4a19a52 100644
--- a/source/benoit/benoit/application/dump.rs
+++ b/source/benoit/benoit/application/dump.rs
@@ -29,8 +29,8 @@ use std::fs::write;
use webp::Encoder;
impl Application {
- pub fn dump(&self, path: String, image: &[u8], canvas_width: u32, canvas_height: u32) {
- let encoder = Encoder::from_rgb(&image[..], canvas_width, canvas_height);
+ pub fn dump(&self, path: String, image: &[u8], canvas_width: u32) {
+ let encoder = Encoder::from_rgb(&image[..], canvas_width, canvas_width);
let data = encoder.encode_lossless();
diff --git a/source/benoit/benoit/application/initialise.rs b/source/benoit/benoit/application/initialise.rs
index 1a24367..2e9eb2b 100644
--- a/source/benoit/benoit/application/initialise.rs
+++ b/source/benoit/benoit/application/initialise.rs
@@ -55,7 +55,7 @@ impl Application {
eprintln!("using {thread_count} threads");
let video = match configuration.interactive {
- true => Some(Video::initialise(configuration.canvas_width, configuration.canvas_height, configuration.scale)),
+ true => Some(Video::initialise(configuration.canvas_width, configuration.scale)),
false => None,
};
@@ -67,10 +67,9 @@ impl Application {
fractal: configuration.fractal,
julia: configuration.julia,
- canvas_width: configuration.canvas_width,
- canvas_height: configuration.canvas_height,
- scale: configuration.scale,
- frame_count: configuration.frame_count,
+ canvas_width: configuration.canvas_width,
+ scale: configuration.scale,
+ frame_count: configuration.frame_count,
centre_real: Float::with_val(PRECISION, configuration.centre_real),
centre_imag: Float::with_val(PRECISION, configuration.centre_imag),
diff --git a/source/benoit/benoit/application/loop.rs b/source/benoit/benoit/application/loop.rs
index 67de1dd..9c5fc55 100644
--- a/source/benoit/benoit/application/loop.rs
+++ b/source/benoit/benoit/application/loop.rs
@@ -50,7 +50,7 @@ impl Application {
let mut event_pump = self.video.as_mut().unwrap().sdl.event_pump().expect("unable to get event pump");
- let canvas_size = self.canvas_height as usize * self.canvas_width as usize;
+ let canvas_size = self.canvas_width as usize * self.canvas_width as usize;
let mut iter_count_buffer: Vec::<u32> = vec![0x0; canvas_size];
let mut square_dist_buffer: Vec::<f32> = vec![0.0; canvas_size];
@@ -85,7 +85,7 @@ impl Application {
let path = format!("{}/image.webp", self.dump_path);
eprintln!("dumping image at \"{path}\"");
- self.dump(path, &image, self.canvas_width, self.canvas_height);
+ self.dump(path, &image, self.canvas_width);
self.do_dump = false;
}
diff --git a/source/benoit/benoit/application/render.rs b/source/benoit/benoit/application/render.rs
index 495f54b..eae4438 100644
--- a/source/benoit/benoit/application/render.rs
+++ b/source/benoit/benoit/application/render.rs
@@ -41,9 +41,9 @@ impl Application {
let row_renderer = self.row_renderer;
let iterator = self.iterator_function;
- let data = Arc::new(RenderData::new(iter_count_buffer, square_dist_buffer, self.canvas_width, self.canvas_height, centre_real.clone(), centre_imag.clone(), zoom.clone(), max_iter_count));
+ let data = Arc::new(RenderData::new(iter_count_buffer, square_dist_buffer, self.canvas_width, centre_real.clone(), centre_imag.clone(), zoom.clone(), max_iter_count));
- (0x0..self.canvas_height).into_par_iter().for_each(|row| {
+ (0x0..self.canvas_width).into_par_iter().for_each(|row| {
row_renderer(data.clone(), row, iterator);
});
diff --git a/source/benoit/benoit/application/render_row_julia.rs b/source/benoit/benoit/application/render_row_julia.rs
index e9f2aa3..7bfa6be 100644
--- a/source/benoit/benoit/application/render_row_julia.rs
+++ b/source/benoit/benoit/application/render_row_julia.rs
@@ -36,8 +36,7 @@ impl Application {
let (iter_count_buffer, square_dist_buffer) = unsafe { data.slice(y) };
for x in 0x0..data.canvas_width {
- let canvas_width = Float::with_val(PRECISION, data.canvas_width);
- let canvas_height = Float::with_val(PRECISION, data.canvas_height);
+ let canvas_width = Float::with_val(PRECISION, data.canvas_width);
let x_float = Float::with_val(PRECISION, x);
let y_float = Float::with_val(PRECISION, y);
@@ -63,11 +62,11 @@ impl Application {
};
let mut zb = {
- let tmp0 = Float::with_val(PRECISION, &canvas_height / 2.0);
+ let tmp0 = Float::with_val(PRECISION, &canvas_width / 2.0);
let mut zb = Float::with_val(PRECISION, &y_float - &tmp0);
zb *= 4.0;
- zb /= &canvas_height;
+ zb /= &canvas_width;
zb
};
diff --git a/source/benoit/benoit/application/render_row_normal.rs b/source/benoit/benoit/application/render_row_normal.rs
index 4dbb4f5..b3d3835 100644
--- a/source/benoit/benoit/application/render_row_normal.rs
+++ b/source/benoit/benoit/application/render_row_normal.rs
@@ -36,8 +36,7 @@ impl Application {
let (iter_count_buffer, square_dist_buffer) = unsafe { data.slice(y) };
for x in 0x0..data.canvas_width {
- let canvas_width = Float::with_val(PRECISION, data.canvas_width);
- let canvas_height = Float::with_val(PRECISION, data.canvas_height);
+ let canvas_width = Float::with_val(PRECISION, data.canvas_width);
let x_float = Float::with_val(PRECISION, x);
let y_float = Float::with_val(PRECISION, y);
@@ -55,11 +54,11 @@ impl Application {
};
let cb = {
- let tmp0 = Float::with_val(PRECISION, &canvas_height / 2.0);
+ let tmp0 = Float::with_val(PRECISION, &canvas_width / 2.0);
let mut cb = Float::with_val(PRECISION, &y_float - &tmp0);
cb *= 4.0;
- cb /= &canvas_height;
+ cb /= &canvas_width;
cb /= &data.zoom;
cb += &data.centre_imag;
diff --git a/source/benoit/benoit/configuration.rs b/source/benoit/benoit/configuration.rs
index d777d2d..ca36400 100644
--- a/source/benoit/benoit/configuration.rs
+++ b/source/benoit/benoit/configuration.rs
@@ -36,10 +36,9 @@ pub struct Configuration {
pub fractal: Fractal,
pub julia: bool,
- pub canvas_width: u32,
- pub canvas_height: u32,
- pub scale: u32,
- pub frame_count: u32,
+ pub canvas_width: u32,
+ pub scale: u32,
+ pub frame_count: u32,
pub centre_real: Float,
pub centre_imag: Float,
diff --git a/source/benoit/benoit/configuration/default.rs b/source/benoit/benoit/configuration/default.rs
index 222a9e4..1d59786 100644
--- a/source/benoit/benoit/configuration/default.rs
+++ b/source/benoit/benoit/configuration/default.rs
@@ -37,10 +37,9 @@ impl Configuration {
fractal: Fractal::Mandelbrot,
julia: false,
- canvas_width: 0x100,
- canvas_height: 0x100,
- scale: 0x2,
- frame_count: 0x10,
+ canvas_width: 0x100,
+ scale: 0x2,
+ frame_count: 0x10,
centre_real: Float::with_val(PRECISION, 0.0),
centre_imag: Float::with_val(PRECISION, 0.0),
diff --git a/source/benoit/benoit/configuration/load.rs b/source/benoit/benoit/configuration/load.rs
index b61189a..ae8c999 100644
--- a/source/benoit/benoit/configuration/load.rs
+++ b/source/benoit/benoit/configuration/load.rs
@@ -96,10 +96,9 @@ impl Configuration {
configuration.fractal
};
- get_integer(&mut configuration.canvas_width, &configuration_table, "canvas_width");
- get_integer(&mut configuration.canvas_height, &configuration_table, "canvas_height");
- get_integer(&mut configuration.scale, &configuration_table, "scale");
- get_integer(&mut configuration.frame_count, &configuration_table, "frame_count");
+ get_integer(&mut configuration.canvas_width, &configuration_table, "canvas_width");
+ get_integer(&mut configuration.scale, &configuration_table, "scale");
+ get_integer(&mut configuration.frame_count, &configuration_table, "frame_count");
get_float( &mut configuration.centre_real, &configuration_table, "real");
get_float( &mut configuration.centre_imag, &configuration_table, "imaginary");
diff --git a/source/benoit/benoit/iteration/iterate_burning_ship.rs b/source/benoit/benoit/iteration/iterate_burning_ship.rs
index 596c021..89d2ec1 100644
--- a/source/benoit/benoit/iteration/iterate_burning_ship.rs
+++ b/source/benoit/benoit/iteration/iterate_burning_ship.rs
@@ -30,7 +30,7 @@ pub fn iterate_burning_ship(za: &mut Float, zb: &mut Float, ca: &Float, cb: &Flo
// iteration - the real and imaginary parts of (z)
// are made absolute:
//
- // z(n) = (abs(Re(z(n)))+i*abs(Im(z(n))))^2+c
+ // z(n+1) = (abs(Re(z(n)))+i*abs(Im(z(n))))^2+c
za.abs_mut();
zb.abs_mut();
diff --git a/source/benoit/benoit/render_data.rs b/source/benoit/benoit/render_data.rs
index 9b93d33..5546e16 100644
--- a/source/benoit/benoit/render_data.rs
+++ b/source/benoit/benoit/render_data.rs
@@ -31,8 +31,7 @@ pub mod slice;
pub mod sync;
pub struct RenderData {
- pub canvas_width: u32,
- pub canvas_height: u32,
+ pub canvas_width: u32,
pub centre_real: Float,
pub centre_imag: Float,
diff --git a/source/benoit/benoit/render_data/new.rs b/source/benoit/benoit/render_data/new.rs
index e779700..4e3f28d 100644
--- a/source/benoit/benoit/render_data/new.rs
+++ b/source/benoit/benoit/render_data/new.rs
@@ -28,13 +28,12 @@ extern crate rug;
use rug::Float;
impl RenderData {
- pub fn new(iter_count_buffer: &mut [u32], square_dist_buffer: &mut [f32], canvas_width: u32, canvas_height: u32, centre_real: Float, centre_imag: Float, zoom: Float, max_iter_count: u32) -> RenderData {
+ pub fn new(iter_count_buffer: &mut [u32], square_dist_buffer: &mut [f32], canvas_width: u32, centre_real: Float, centre_imag: Float, zoom: Float, max_iter_count: u32) -> RenderData {
let iter_count_buffer_pointer = iter_count_buffer.as_mut_ptr();
let square_dist_buffer_pointer = square_dist_buffer.as_mut_ptr();
return RenderData {
- canvas_width: canvas_width,
- canvas_height: canvas_height,
+ canvas_width: canvas_width,
centre_real: centre_real,
centre_imag: centre_imag,
diff --git a/source/benoit/benoit/video/initialise.rs b/source/benoit/benoit/video/initialise.rs
index 595140d..15449fd 100644
--- a/source/benoit/benoit/video/initialise.rs
+++ b/source/benoit/benoit/video/initialise.rs
@@ -26,11 +26,11 @@ use crate::benoit::video::Video;
extern crate sdl2;
impl Video {
- pub fn initialise(canvas_width: u32, canvas_height: u32, scale: u32) -> Video {
+ pub fn initialise(canvas_width: u32, scale: u32) -> Video {
let sdl = sdl2::init().expect("unable to initialise sdl2");
let sdl_video = sdl.video().expect("unable to initialise video");
- let window = sdl_video.window("Benoit", canvas_width * scale, canvas_height * scale).position_centered().build().expect("unable to open window");
+ let window = sdl_video.window("Benoit", canvas_width * scale, canvas_width * scale).position_centered().build().expect("unable to open window");
let canvas = window.into_canvas().build().expect("unable to create canvas");