wuple 0.4.0

Simple, Performant rendering on WGPU
Documentation
use winit::window::Window;

pub struct Info<'a> {
    pub(crate) window: &'a Window,
}

impl<'a> Info<'a> {
    /// Convert from pixels to units
    pub fn from_pixel(&self, pos: (f32, f32)) -> (f32, f32) {
        let size = self.size();
        (pos.0 / size.0 as f32, pos.1 / size.1 as f32)
    }

    /// Convert from screen space in pixels to world space in units
    pub fn from_screen(&self, pos: (f32, f32)) -> (f32, f32) {
        let size = self.size();
        self.from_pixel((pos.0 * 2.0 - size.0 as f32, pos.1 * 2.0 + size.1 as f32))
    }

    /// Get the window size
    pub fn size(&self) -> (u32, u32) {
        self.window.inner_size().into()
    }

    pub fn set_title(&self, title: &str) {
        self.window.set_title(title);
    }
}