@@ 68,15 68,20 @@ fn main() -> Result<(), pixels::Error> {
.build(&event_loop)
.unwrap();
+ let background = colors::BLACK;
let pixels = {
let PhysicalSize { width, height } = window.inner_size();
let surface_texture = SurfaceTexture::new(width, height, &window);
PixelsBuilder::new(width, height, surface_texture)
+ .clear_color({
+ let [r, g, b, a] = background.map(|v| v as f64 / u8::MAX as f64);
+ pixels::wgpu::Color { r, g, b, a }
+ })
.present_mode(pixels::wgpu::PresentMode::AutoVsync)
.blend_state(pixels::wgpu::BlendState::ALPHA_BLENDING)
.build()?
};
- let mut screen = Screen::new(pixels);
+ let mut screen = Screen::new(pixels, background);
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
@@ 11,10 11,10 @@ pub struct Screen {
}
impl Screen {
- pub fn new(pixels: Pixels) -> Self {
+ pub fn new(pixels: Pixels, clear_color: Pixel) -> Self {
Self {
pixels,
- clear_color: [0x00; PIXEL_SIZE],
+ clear_color,
old_list: Vec::new(),
}
}