@@ -295,11 +295,7 @@ impl App {
295295 self . plot . update ( width, height, & mut v) ;
296296 }
297297 let canvas = self . plot . canvas . as_ref ( ) . unwrap ( ) ;
298- draw_buffer_web (
299- self . window . as_ref ( ) . unwrap ( ) ,
300- canvas. width ( ) ,
301- wasm_bindgen:: Clamped ( canvas. data ( ) ) ,
302- ) ;
298+ crate :: draw ( canvas. data ( ) , canvas. width ( ) ) ;
303299 if b {
304300 let name = self . name . clone ( ) ;
305301 if let Some ( w) = self . window ( ) {
@@ -326,21 +322,7 @@ impl App {
326322 b = true ;
327323 self . name = n;
328324 } ;
329- use wasm_bindgen:: prelude:: * ;
330- use winit:: platform:: web:: WindowExtWebSys ;
331- let canvas: web_sys:: HtmlCanvasElement = self
332- . window
333- . as_ref ( )
334- . unwrap ( )
335- . canvas ( )
336- . expect ( "Failed to get canvas" ) ;
337- let ctx: web_sys:: CanvasRenderingContext2d = canvas
338- . get_context ( "2d" )
339- . expect ( "Failed to get 2d context" )
340- . expect ( "Failed to get 2d context" )
341- . dyn_into ( )
342- . expect ( "Failed to convert to CanvasRenderingContext2d" ) ;
343- self . plot . update ( width, height, ctx) ;
325+ self . plot . update ( width, height) ;
344326 if b {
345327 let name = self . name . clone ( ) ;
346328 if let Some ( w) = self . window ( ) {
@@ -353,23 +335,3 @@ impl App {
353335 }
354336 }
355337}
356- #[ cfg( all( feature = "wasm" , feature = "tiny-skia" ) ) ]
357- fn draw_buffer_web ( win : & winit:: window:: Window , width : u32 , clamped : wasm_bindgen:: Clamped < & [ u8 ] > ) {
358- use wasm_bindgen:: prelude:: * ;
359- let canvas = get_a_canvas ( win) ;
360- let ctx: web_sys:: CanvasRenderingContext2d = canvas
361- . get_context ( "2d" )
362- . expect ( "Failed to get 2d context" )
363- . expect ( "Failed to get 2d context" )
364- . dyn_into ( )
365- . expect ( "Failed to convert to CanvasRenderingContext2d" ) ;
366- let image = web_sys:: ImageData :: new_with_u8_clamped_array ( clamped, width)
367- . expect ( "Failed to create image data" ) ;
368- ctx. put_image_data ( & image, 0.0 , 0.0 )
369- . expect ( "Failed to put image data" ) ;
370-
371- fn get_a_canvas ( win : & winit:: window:: Window ) -> web_sys:: HtmlCanvasElement {
372- use winit:: platform:: web:: WindowExtWebSys ;
373- win. canvas ( ) . expect ( "Failed to get canvas" )
374- }
375- }
0 commit comments