Skip to content

Commit

Permalink
added color argument to fill::fill_window on examples/util/fill
Browse files Browse the repository at this point in the history
  • Loading branch information
Sl-L committed Dec 23, 2024
1 parent d736763 commit eecb00b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ApplicationHandler for ControlFlowDemo {
WindowEvent::RedrawRequested => {
let window = self.window.as_ref().unwrap();
window.pre_present_notify();
fill::fill_window(window.as_ref());
fill::fill_window(window.as_ref(), 0xff181818);
},
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion examples/pump_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn main() -> std::process::ExitCode {
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::RedrawRequested => {
fill::fill_window(window.as_ref());
fill::fill_window(window.as_ref(), 0xff181818);
window.request_redraw();
},
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion examples/run_on_demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
self.window = None;
},
WindowEvent::RedrawRequested => {
fill::fill_window(window.as_ref());
fill::fill_window(window.as_ref(), 0xff181818);
},
_ => (),
}
Expand Down
7 changes: 3 additions & 4 deletions examples/util/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod platform {
}
}

pub fn fill_window(window: &dyn Window) {
pub fn fill_window(window: &dyn Window, color: u32) {
GC.with(|gc| {
let size = window.surface_size();
let (Some(width), Some(height)) =
Expand All @@ -84,13 +84,12 @@ mod platform {
let surface =
gc.get_or_insert_with(|| GraphicsContext::new(window)).create_surface(window);

// Fill a buffer with a solid color.
const DARK_GRAY: u32 = 0xff181818;
// Fill a buffer with a solid color

surface.resize(width, height).expect("Failed to resize the softbuffer surface");

let mut buffer = surface.buffer_mut().expect("Failed to get the softbuffer buffer");
buffer.fill(DARK_GRAY);
buffer.fill(color);
buffer.present().expect("Failed to present the softbuffer buffer");
})
}
Expand Down
2 changes: 1 addition & 1 deletion examples/x11_embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() -> Result<(), Box<dyn Error>> {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::RedrawRequested => {
window.pre_present_notify();
fill::fill_window(window.as_ref());
fill::fill_window(window.as_ref(), 0xff181818);
},
_ => (),
}
Expand Down

0 comments on commit eecb00b

Please sign in to comment.