@@ -16,7 +16,7 @@ pub struct FractalRenderer {
1616 zoom : FloatExtended ,
1717 auto_adjust_iterations : bool ,
1818 maximum_iteration : usize ,
19- glitch_tolerance : f64 ,
19+ glitch_percentage : f64 ,
2020 data_export : DataExport ,
2121 start_render_time : Instant ,
2222 remaining_frames : usize ,
@@ -39,7 +39,7 @@ impl FractalRenderer {
3939 let center_real = settings. get_str ( "real" ) . unwrap_or ( String :: from ( "-0.75" ) ) ;
4040 let center_imag = settings. get_str ( "imag" ) . unwrap_or ( String :: from ( "0.0" ) ) ;
4141 let approximation_order = settings. get_int ( "approximation_order" ) . unwrap_or ( 0 ) as usize ;
42- let glitch_tolerance = settings. get_float ( "glitch_tolerance " ) . unwrap_or ( 0.001 ) ;
42+ let glitch_percentage = settings. get_float ( "glitch_percentage " ) . unwrap_or ( 0.001 ) ;
4343 let remaining_frames = settings. get_int ( "frames" ) . unwrap_or ( 1 ) as usize ;
4444 let frame_offset = settings. get_int ( "frame_offset" ) . unwrap_or ( 0 ) as usize ;
4545 let zoom_scale_factor = settings. get_float ( "zoom_scale" ) . unwrap_or ( 2.0 ) ;
@@ -51,6 +51,7 @@ impl FractalRenderer {
5151 let iteration_division = settings. get_float ( "iteration_division" ) . unwrap_or ( 0.1 ) as f32 ;
5252 let valid_iteration_frame_multiplier = settings. get_float ( "valid_iteration_frame_multiplier" ) . unwrap_or ( 0.75 ) as f32 ;
5353 let valid_iteration_probe_multiplier = settings. get_float ( "valid_iteration_probe_multiplier" ) . unwrap_or ( 0.98 ) as f32 ;
54+ let glitch_tolerance = settings. get_float ( "glitch_tolerance" ) . unwrap_or ( 1e-6 ) as f64 ;
5455 let high_precision_data_interval = settings. get_int ( "high_precision_data_interval" ) . unwrap_or ( 100 ) as usize ;
5556
5657 let data_type = match settings. get_str ( "export" ) . unwrap_or ( String :: from ( "COLOUR" ) ) . to_ascii_uppercase ( ) . as_ref ( ) {
@@ -93,7 +94,8 @@ impl FractalRenderer {
9394 center_location. clone ( ) ,
9495 1 ,
9596 maximum_iteration,
96- high_precision_data_interval) ;
97+ high_precision_data_interval,
98+ glitch_tolerance) ;
9799
98100 let series_approximation = SeriesApproximation :: new_central ( & center_location,
99101 auto_approximation,
@@ -121,7 +123,7 @@ impl FractalRenderer {
121123 zoom,
122124 auto_adjust_iterations,
123125 maximum_iteration,
124- glitch_tolerance ,
126+ glitch_percentage ,
125127 data_export : DataExport :: new ( image_width, image_height, display_glitches, data_type, palette, iteration_division) ,
126128 start_render_time : Instant :: now ( ) ,
127129 remaining_frames,
@@ -240,10 +242,12 @@ impl FractalRenderer {
240242 iteration : chosen_iteration,
241243 delta_centre : point_delta,
242244 delta_reference : point_delta,
243- delta_current : new_delta,
245+ delta_current : new_delta. clone ( ) ,
244246 derivative_current : ComplexFixed :: new ( 1.0 , 0.0 ) ,
245247 glitched : false ,
246- escaped : false
248+ escaped : false ,
249+ series_approximation_delta : new_delta,
250+ series_approximation_iteration : chosen_iteration
247251 }
248252 } ) . collect :: < Vec < PixelData > > ( ) ;
249253
@@ -260,19 +264,24 @@ impl FractalRenderer {
260264 std:: io:: stdout ( ) . flush ( ) . unwrap ( ) ;
261265
262266 let correction_time = Instant :: now ( ) ;
267+ let mut correction_references = 1 ;
263268
264269 // Remove all non-glitched points from the remaining points
265270 pixel_data. retain ( |packet| {
266271 packet. glitched
267272 } ) ;
268273
269- while pixel_data. len ( ) as f64 > 0.01 * self . glitch_tolerance * ( self . image_width * self . image_height ) as f64 {
274+ while pixel_data. len ( ) as f64 > 0.01 * self . glitch_percentage * ( self . image_width * self . image_height ) as f64 {
270275 // delta_c is the difference from the next reference from the previous one
276+
271277 let glitch_reference_pixel = pixel_data. choose ( & mut rand:: thread_rng ( ) ) . unwrap ( ) . clone ( ) ;
272278
273279 let mut glitch_reference = self . series_approximation . get_reference ( glitch_reference_pixel. delta_centre , & self . center_reference ) ;
280+
281+ correction_references += 1 ;
274282 glitch_reference. run ( ) ;
275283
284+
276285 let delta_current_reference = self . series_approximation . evaluate ( glitch_reference_pixel. delta_centre , glitch_reference. start_iteration ) ;
277286
278287 pixel_data. par_iter_mut ( )
@@ -281,7 +290,8 @@ impl FractalRenderer {
281290 pixel. glitched = false ;
282291 pixel. delta_current = self . series_approximation . evaluate ( pixel. delta_centre , glitch_reference. start_iteration ) - delta_current_reference;
283292 pixel. delta_reference = pixel. delta_centre - glitch_reference_pixel. delta_centre ;
284- } ) ;
293+ } ) ;
294+
285295
286296 Perturbation :: iterate ( & mut pixel_data, & glitch_reference) ;
287297 self . data_export . export_pixels ( & pixel_data, self . maximum_iteration , & glitch_reference) ;
@@ -292,6 +302,7 @@ impl FractalRenderer {
292302 } ) ;
293303 }
294304
305+ print ! ( "| {:<6}" , correction_references) ;
295306 print ! ( "| {:<15}" , correction_time. elapsed( ) . as_millis( ) ) ;
296307 std:: io:: stdout ( ) . flush ( ) . unwrap ( ) ;
297308
@@ -304,7 +315,7 @@ impl FractalRenderer {
304315
305316 pub fn render ( & mut self ) {
306317 // Print out the status information
307- println ! ( "{:<6}| {:<15}| {:<15}| {:<15}| {:<6}| {:<15}| {:<15}| {:<15}| {:<15}| {:<15}| {:<15}| {:<15}" , "Frame" , "Zoom" , "Approx [ms]" , "Skipped [it]" , "Order" , "Maximum [it]" , "Packing [ms]" , "Iteration [ms]" , "Correct [ms]" , "Saving [ms]" , "Frame [ms]" , "TOTAL [ms]" ) ;
318+ println ! ( "{:<6}| {:<15}| {:<15}| {:<15}| {:<6}| {:<15}| {:<15}| {:<15}| {:<6}| {:< 15}| {:<15}| {:<15}| {:<15}" , "Frame" , "Zoom" , "Approx [ms]" , "Skipped [it]" , "Order" , "Maximum [it]" , "Packing [ms]" , "Iteration [ms]" , "Ref ", "Correct [ms]" , "Saving [ms]" , "Frame [ms]" , "TOTAL [ms]" ) ;
308319
309320 let mut count = 0 ;
310321
0 commit comments