use super::Window;
use crate::graphics::{Color, Gpu, Target};
#[derive(Debug)]
pub struct Frame<'a> {
window: &'a mut Window,
}
impl<'a> Frame<'a> {
pub(crate) fn new(window: &mut Window) -> Frame<'_> {
Frame { window }
}
pub fn gpu(&mut self) -> &mut Gpu {
self.window.gpu()
}
pub fn width(&self) -> f32 {
self.window.width
}
pub fn height(&self) -> f32 {
self.window.height
}
pub fn as_target(&mut self) -> Target<'_> {
let Window {
surface,
gpu,
width,
height,
..
} = &mut self.window;
let view = surface.target();
Target::new(gpu, view, *width, *height)
}
pub fn clear(&mut self, color: Color) {
self.as_target().clear(color);
}
}