fn redraw(&mut self) {
        self.vat = Arc::new(ViewAreaTransformer::new(
            self.screen_size,
            self.view_area[0],
            self.view_area[1],
        ));
        log::debug!("view area: {:?}", self.view_area);
        log::debug!(
            "pixel 0,0 maps to {}",
            self.vat.map_pixel_to_point([0.0, 0.0])
        );
        log::debug!(
            "pixel {},{} maps to {}",
            self.screen_size[0] as u32,
            self.screen_size[1] as u32,
            self.vat.map_pixel_to_point(self.screen_size)
        );
        let colors = Arc::new(color::color_range_linear(
            color::BLACK_U8,
            color::WHITE_U8,
            cmp::min(self.etsystem.max_iterations(), 50) as usize,
        ));

        self.canvas = Arc::new(RwLock::new(FractalImageBuffer::new(
            self.screen_size[0] as u32,
            self.screen_size[1] as u32,
        )));

        {
            let shared_canvas = (&self.canvas).clone();
            let vat = Arc::clone(&self.vat);
            let etsystem = Arc::clone(&self.etsystem);
            let colors = Arc::clone(&colors);
            let tl = [0.0, 0.0];
            let br = self.screen_size;

            let work_muxer = ThreadedWorkMultiplexerBuilder::new()
                .base_name("escapetime_render")
                .split_work(move |thread_id, total_threads, notifier, name| {
                    // Each thread will process x values, sharded by the number of
                    // threads.
                    //
                    // no `step_by` in stable yet.
                    let sequence = ((tl[0] as u32)..(br[0] as u32))
                        .enumerate()
                        .filter(|&(index, _)| (index + thread_id) % total_threads == 0)
                        .map(|(_, val)| val);
                    for x in sequence {
                        if notifier.should_i_stop() {
                            log::debug!("{}: Remote side disconnected", name);
                            break;
                        }
                        let y_colors = ((tl[1] as u32)..(br[1] as u32))
                            .map(|y| {
                                let c: Complex64 =
                                    vat.map_pixel_to_point([f64::from(x), f64::from(y)]).into();
                                let (attracted, time) = etsystem.test_point(c);
                                if attracted {
                                    Rgba(color::AEBLUE_U8.0)
                                } else {
                                    Rgba(colors[cmp::min(time, 50 - 1) as usize].0)
                                }
                            })
                            .collect::<Vec<Rgba<u8>>>();
                        // only lock the canvas while writing to it
                        {
                            // Write a column at a time to improve performance. Locking for every
                            // pixel actually winds up harming performance, but a column at a time
                            // seems to work much better. Haven't tested trying to do multiple
                            // columns at once yet.
                            let mut canvas = shared_canvas.write().unwrap();
                            for (y, color) in y_colors.into_iter().enumerate() {
                                canvas.put_pixel(x, y as u32, color);
                            }
                        }
                    }
                });
            self.threads = Some(work_muxer);
        }
    }
/// Recomputes the fractal for the screen. This should usually be called after the
/// screen/window is resized, or after a new area is selected for viewing.
Recomputes the fractal for the screen. This should usually be called after the
screen/window is resized, or after a new area is selected for viewing.
Recomputes the fractal for the screen . This should usually be called after the screen / window is resized or after a new area is selected for viewing .
fn redraw(&mut self) {
        self.vat = Arc::new(ViewAreaTransformer::new(
            self.screen_size,
            self.view_area[0],
            self.view_area[1],
        ));
        log::debug!("view area: {:?}", self.view_area);
        log::debug!(
            "pixel 0,0 maps to {}",
            self.vat.map_pixel_to_point([0.0, 0.0])
        );
        log::debug!(
            "pixel {},{} maps to {}",
            self.screen_size[0] as u32,
            self.screen_size[1] as u32,
            self.vat.map_pixel_to_point(self.screen_size)
        );
        let colors = Arc::new(color::color_range_linear(
            color::BLACK_U8,
            color::WHITE_U8,
            cmp::min(self.etsystem.max_iterations(), 50) as usize,
        ));
        self.canvas = Arc::new(RwLock::new(FractalImageBuffer::new(
            self.screen_size[0] as u32,
            self.screen_size[1] as u32,
        )));
        {
            let shared_canvas = (&self.canvas).clone();
            let vat = Arc::clone(&self.vat);
            let etsystem = Arc::clone(&self.etsystem);
            let colors = Arc::clone(&colors);
            let tl = [0.0, 0.0];
            let br = self.screen_size;
            let work_muxer = ThreadedWorkMultiplexerBuilder::new()
                .base_name("escapetime_render")
                .split_work(move |thread_id, total_threads, notifier, name| {
                    // Each thread will process x values, sharded by the number of
                    // threads.
                    //
                    // no `step_by` in stable yet.
                    let sequence = ((tl[0] as u32)..(br[0] as u32))
                        .enumerate()
                        .filter(|&(index, _)| (index + thread_id) % total_threads == 0)
                        .map(|(_, val)| val);
                    for x in sequence {
                        if notifier.should_i_stop() {
                            log::debug!("{}: Remote side disconnected", name);
                            break;
                        }
                        let y_colors = ((tl[1] as u32)..(br[1] as u32))
                            .map(|y| {
                                let c: Complex64 =
                                    vat.map_pixel_to_point([f64::from(x), f64::from(y)]).into();
                                let (attracted, time) = etsystem.test_point(c);
                                if attracted {
                                    Rgba(color::AEBLUE_U8.0)
                                } else {
                                    Rgba(colors[cmp::min(time, 50 - 1) as usize].0)
                                }
                            })
                            .collect::<Vec<Rgba<u8>>>();
                        // only lock the canvas while writing to it
                        {
                            // Write a column at a time to improve performance. Locking for every
                            // pixel actually winds up harming performance, but a column at a time
                            // seems to work much better. Haven't tested trying to do multiple
                            // columns at once yet.
                            let mut canvas = shared_canvas.write().unwrap();
                            for (y, color) in y_colors.into_iter().enumerate() {
                                canvas.put_pixel(x, y as u32, color);
                            }
                        }
                    }
                });
            self.threads = Some(work_muxer);
        }
    }
fn redraw ( & mut self ) { self . vat = Arc :: new ( ViewAreaTransformer :: new ( self . screen_size , self . view_area [ 0 ] , self . view_area [ 1 ] , ) ) ; log :: debug ! ( " " self view_area ) ; log :: debug ! ( " " self vat map_pixel_to_point ( [ 0.0 0.0 ] ) ) ; log :: debug ! ( " " self screen_size [ 0 ] as u32 self screen_size [ 1 ] as u32 self vat map_pixel_to_point ( self screen_size ) ) ; let colors = Arc :: new ( color :: color_range_linear ( color :: BLACK_U8 , color :: WHITE_U8 , cmp :: min ( self . etsystem . max_iterations ( ) , 50 ) as usize , ) ) ; self . canvas = Arc :: new ( RwLock :: new ( FractalImageBuffer :: new ( self . screen_size [ 0 ] as u32 , self . screen_size [ 1 ] as u32 , ) ) ) ; { let shared_canvas = ( & self . canvas ) . clone ( ) ; let vat = Arc :: clone ( & self . vat ) ; let etsystem = Arc :: clone ( & self . etsystem ) ; let colors = Arc :: clone ( & colors ) ; let tl = [ 0.0 , 0.0 ] ; let br = self . screen_size ; let work_muxer = ThreadedWorkMultiplexerBuilder :: new ( ) . base_name ( " " ) . split_work ( move | thread_id , total_threads , notifier , name | { // Each thread will process x values, sharded by the number of // threads. // // no `step_by` in stable yet. let sequence = ( ( tl [ 0 ] as u32 ) .. ( br [ 0 ] as u32 ) ) . enumerate ( ) . filter ( | & ( index , _ ) | ( index + thread_id ) % total_threads == 0 ) . map ( | ( _ , val ) | val ) ; for x in sequence { if notifier . should_i_stop ( ) { log :: debug ! ( " " name ) ; break ; } let y_colors = ( ( tl [ 1 ] as u32 ) .. ( br [ 1 ] as u32 ) ) . map ( | y | { let c : Complex64 = vat . map_pixel_to_point ( [ f64 :: from ( x ) , f64 :: from ( y ) ] ) . into ( ) ; let ( attracted , time ) = etsystem . test_point ( c ) ; if attracted { Rgba ( color :: AEBLUE_U8 . 0 ) } else { Rgba ( colors [ cmp :: min ( time , 50 - 1 ) as usize ] . 0 ) } } ) . collect :: < Vec < Rgba < u8 > > > ( ) ; // only lock the canvas while writing to it { // Write a column at a time to improve performance. Locking for every // pixel actually winds up harming performance, but a column at a time // seems to work much better. Haven't tested trying to do multiple // columns at once yet. let mut canvas = shared_canvas . write ( ) . unwrap ( ) ; for ( y , color ) in y_colors . into_iter ( ) . enumerate ( ) { canvas . put_pixel ( x , y as u32 , color ) ; } } } } ) ; self . threads = Some ( work_muxer ) ; } }
Recomputes the fractal for the screen.
Recomputes the fractal for the screen .
&mut self