rust/lib-hedgewars-engine/src/render/camera.rs
author alfadur
Fri, 22 Mar 2019 21:09:17 +0300
changeset 14708 19358c313ebb
parent 14705 19122a329774
child 14709 65c971417780
permissions -rw-r--r--
fix texture initialization

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: 1.0,
            size,
        }
    }

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