author | alfadur |
Fri, 22 Mar 2019 21:09:17 +0300 | |
changeset 14729 | 19358c313ebb |
parent 14726 | 19122a329774 |
child 14730 | 65c971417780 |
permissions | -rw-r--r-- |
14725 | 1 |
use integral_geometry::{Point, Rect, Size}; |
2 |
||
3 |
#[derive(Debug)] |
|
4 |
pub struct Camera { |
|
5 |
pub position: Point, |
|
6 |
pub zoom: f32, |
|
14726 | 7 |
size: Size, |
14725 | 8 |
} |
9 |
||
10 |
impl Camera { |
|
11 |
pub fn new() -> Self { |
|
14726 | 12 |
Self::with_size(Size::new(1024, 768)) |
13 |
} |
|
14 |
||
15 |
pub fn with_size(size: Size) -> Self { |
|
16 |
Self { |
|
17 |
position: Point::ZERO, |
|
14729 | 18 |
zoom: 1.0, |
14726 | 19 |
size, |
20 |
} |
|
14725 | 21 |
} |
22 |
||
23 |
pub fn viewport(&self) -> Rect { |
|
24 |
Rect::from_size(self.position, self.size) |
|
25 |
} |
|
14726 | 26 |
} |