From bafb07a9f1a2eb46d03be7652ff18e59b36eb7bc Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 22 Jun 2024 08:23:31 -0700 Subject: [PATCH] bugfix: Fix CI errors - Remove the default features of the image crate. - Remove needless doctest from README.md Signed-off-by: John Nunley --- Cargo.toml | 1 - README.md | 100 ++++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 873322d..8a1eabf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,6 @@ features = ["jpeg"] [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] # Turn rayon back on everywhere else; creating the separate entry resets the features to default. -image = "0.25.0" rayon = "1.5.1" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] diff --git a/README.md b/README.md index 3e39db6..bb6d68c 100644 --- a/README.md +++ b/README.md @@ -71,60 +71,58 @@ use winit::window::Window; include!("../examples/utils/winit_app.rs"); -fn main() { - let event_loop = EventLoop::new().unwrap(); - - let mut app = winit_app::WinitAppBuilder::with_init(|elwt| { - let window = { - let window = elwt.create_window(Window::default_attributes()); - Rc::new(window.unwrap()) - }; - let context = softbuffer::Context::new(window.clone()).unwrap(); - let surface = softbuffer::Surface::new(&context, window.clone()).unwrap(); - - (window, surface) - }).with_event_handler(|state, event, elwt| { - let (window, surface) = state; - elwt.set_control_flow(ControlFlow::Wait); - - match event { - Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested } if window_id == window.id() => { - let (width, height) = { - let size = window.inner_size(); - (size.width, size.height) - }; - surface - .resize( - NonZeroU32::new(width).unwrap(), - NonZeroU32::new(height).unwrap(), - ) - .unwrap(); - - let mut buffer = surface.buffer_mut().unwrap(); - for index in 0..(width * height) { - let y = index / width; - let x = index % width; - let red = x % 255; - let green = y % 255; - let blue = (x * y) % 255; - - buffer[index as usize] = blue | (green << 8) | (red << 16); - } - - buffer.present().unwrap(); +let event_loop = EventLoop::new().unwrap(); + +let mut app = winit_app::WinitAppBuilder::with_init(|elwt| { + let window = { + let window = elwt.create_window(Window::default_attributes()); + Rc::new(window.unwrap()) + }; + let context = softbuffer::Context::new(window.clone()).unwrap(); + let surface = softbuffer::Surface::new(&context, window.clone()).unwrap(); + + (window, surface) +}).with_event_handler(|state, event, elwt| { + let (window, surface) = state; + elwt.set_control_flow(ControlFlow::Wait); + + match event { + Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested } if window_id == window.id() => { + let (width, height) = { + let size = window.inner_size(); + (size.width, size.height) + }; + surface + .resize( + NonZeroU32::new(width).unwrap(), + NonZeroU32::new(height).unwrap(), + ) + .unwrap(); + + let mut buffer = surface.buffer_mut().unwrap(); + for index in 0..(width * height) { + let y = index / width; + let x = index % width; + let red = x % 255; + let green = y % 255; + let blue = (x * y) % 255; + + buffer[index as usize] = blue | (green << 8) | (red << 16); } - Event::WindowEvent { - event: WindowEvent::CloseRequested, - window_id, - } if window_id == window.id() => { - elwt.exit(); - } - _ => {} + + buffer.present().unwrap(); + } + Event::WindowEvent { + event: WindowEvent::CloseRequested, + window_id, + } if window_id == window.id() => { + elwt.exit(); } - }); + _ => {} + } +}); - event_loop.run_app(&mut app).unwrap(); -} +event_loop.run_app(&mut app).unwrap(); ``` Changelog