rust/lib-hedgewars-engine/src/render/camera.rs
author alfadur
Fri, 22 Mar 2019 20:26:29 +0300
changeset 14726 19122a329774
parent 14725 12db7e435ea6
child 14729 19358c313ebb
permissions -rw-r--r--
make world renderer optional + fmt

use integral_geometry::{Point, Rect, Size};

#[derive(Debug)]
pub struct Camera {
    pub position: Point,
    pub zoom: f32,
    size: Size,
}

impl Camera {
    pub fn new() -> Self {
        Self::with_size(Size::new(1024, 768))
    }

    pub fn with_size(size: Size) -> Self {
        Self {
            position: Point::ZERO,
            zoom: 0.0,
            size,
        }
    }

    pub fn viewport(&self) -> Rect {
        Rect::from_size(self.position, self.size)
    }
}