fn show_title(canvas: &DrawingTarget, layer: LayerId, crossfade: Binding<f32>) {
    let canvas = canvas.clone();

    thread::Builder::new()
        .name("Title thread".into())
        .spawn(move || {
            // Draw the title with a cross-fade
            for fade in 0..=180 {
                // Update the crossfade factor for the other threads. Fade goes from 0.0 to 2.0
                let fade = (fade as f32) / 90.0;
                crossfade.set(fade);

                // Draw the title, with a cross fade to show the mandelbrot set
                canvas.draw(|gc| {
                    gc.layer(layer);
                    gc.clear_layer();

                    gc.canvas_height(1000.0);
                    gc.center_region(0.0, 0.0, 1000.0, 1000.0);

                    let title_fade = (2.0-fade) - 0.5;
                    let title_fade = f32::min(f32::max(title_fade, 0.0), 1.0);

                    // Title card
                    gc.fill_color(Color::Rgba(0.0, 0.0, 0.6, title_fade));
                    gc.set_font_size(FontId(2), 36.0);
                    gc.begin_line_layout(500.0, 482.0 + (title_fade*4.0), TextAlignment::Center);
                    gc.layout_text(FontId(2), "Mandelbrot set".into());
                    gc.draw_text_layout();

                    gc.set_font_size(FontId(1), 16.0);
                    gc.begin_line_layout(500.0, 430.0 - (title_fade*4.0), TextAlignment::Center);
                    gc.layout_text(FontId(1), "A flo_draw demonstration".into());
                    gc.draw_text_layout();

                    gc.begin_line_layout(500.0, 400.0, TextAlignment::Center);
                    gc.layout_text(FontId(1), "Written by Andrew Hunter".into());
                    gc.draw_text_layout();
                });

                // Fade at 60fps
                thread::sleep(Duration::from_nanos(1_000_000_000 / 60));
            }

            // Blank the layer once done
            canvas.draw(|gc| {
                gc.layer(layer);
                gc.clear_layer();
            });
        })
        .unwrap();
}
///
/// Runs a thread that shows the title 
///
Runs a thread that shows the title
Runs a thread that shows the title
fn show_title(canvas: &DrawingTarget, layer: LayerId, crossfade: Binding<f32>) {
    let canvas = canvas.clone();
    thread::Builder::new()
        .name("Title thread".into())
        .spawn(move || {
            // Draw the title with a cross-fade
            for fade in 0..=180 {
                // Update the crossfade factor for the other threads. Fade goes from 0.0 to 2.0
                let fade = (fade as f32) / 90.0;
                crossfade.set(fade);
                // Draw the title, with a cross fade to show the mandelbrot set
                canvas.draw(|gc| {
                    gc.layer(layer);
                    gc.clear_layer();
                    gc.canvas_height(1000.0);
                    gc.center_region(0.0, 0.0, 1000.0, 1000.0);
                    let title_fade = (2.0-fade) - 0.5;
                    let title_fade = f32::min(f32::max(title_fade, 0.0), 1.0);
                    // Title card
                    gc.fill_color(Color::Rgba(0.0, 0.0, 0.6, title_fade));
                    gc.set_font_size(FontId(2), 36.0);
                    gc.begin_line_layout(500.0, 482.0 + (title_fade*4.0), TextAlignment::Center);
                    gc.layout_text(FontId(2), "Mandelbrot set".into());
                    gc.draw_text_layout();
                    gc.set_font_size(FontId(1), 16.0);
                    gc.begin_line_layout(500.0, 430.0 - (title_fade*4.0), TextAlignment::Center);
                    gc.layout_text(FontId(1), "A flo_draw demonstration".into());
                    gc.draw_text_layout();
                    gc.begin_line_layout(500.0, 400.0, TextAlignment::Center);
                    gc.layout_text(FontId(1), "Written by Andrew Hunter".into());
                    gc.draw_text_layout();
                });
                // Fade at 60fps
                thread::sleep(Duration::from_nanos(1_000_000_000 / 60));
            }
            // Blank the layer once done
            canvas.draw(|gc| {
                gc.layer(layer);
                gc.clear_layer();
            });
        })
        .unwrap();
}
fn show_title ( canvas : & DrawingTarget , layer : LayerId , crossfade : Binding < f32 > ) { let canvas = canvas . clone ( ) ; thread :: Builder :: new ( ) . name ( " " . into ( ) ) . spawn ( move | | { // Draw the title with a cross-fade for fade in 0 ..= 180 { // Update the crossfade factor for the other threads. Fade goes from 0.0 to 2.0 let fade = ( fade as f32 ) / 90.0 ; crossfade . set ( fade ) ; // Draw the title, with a cross fade to show the mandelbrot set canvas . draw ( | gc | { gc . layer ( layer ) ; gc . clear_layer ( ) ; gc . canvas_height ( 1000.0 ) ; gc . center_region ( 0.0 , 0.0 , 1000.0 , 1000.0 ) ; let title_fade = ( 2.0 - fade ) - 0.5 ; let title_fade = f32 :: min ( f32 :: max ( title_fade , 0.0 ) , 1.0 ) ; // Title card gc . fill_color ( Color :: Rgba ( 0.0 , 0.0 , 0.6 , title_fade ) ) ; gc . set_font_size ( FontId ( 2 ) , 36.0 ) ; gc . begin_line_layout ( 500.0 , 482.0 + ( title_fade * 4.0 ) , TextAlignment :: Center ) ; gc . layout_text ( FontId ( 2 ) , " " . into ( ) ) ; gc . draw_text_layout ( ) ; gc . set_font_size ( FontId ( 1 ) , 16.0 ) ; gc . begin_line_layout ( 500.0 , 430.0 - ( title_fade * 4.0 ) , TextAlignment :: Center ) ; gc . layout_text ( FontId ( 1 ) , " " . into ( ) ) ; gc . draw_text_layout ( ) ; gc . begin_line_layout ( 500.0 , 400.0 , TextAlignment :: Center ) ; gc . layout_text ( FontId ( 1 ) , " " . into ( ) ) ; gc . draw_text_layout ( ) ; } ) ; // Fade at 60fps thread :: sleep ( Duration :: from_nanos ( 1_000_000_000 / 60 ) ) ; } // Blank the layer once done canvas . draw ( | gc | { gc . layer ( layer ) ; gc . clear_layer ( ) ; } ) ; } ) . unwrap ( ) ; }
Runs a thread that shows the title
Runs a thread that shows the title
canvas
&DrawingTarget
layer
LayerId
crossfade
Binding<f32>