rust/lib-hedgewars-engine/src/render/camera.rs
changeset 14709 65c971417780
parent 14708 19358c313ebb
child 14718 5915a199cb81
equal deleted inserted replaced
14708:19358c313ebb 14709:65c971417780
    19             size,
    19             size,
    20         }
    20         }
    21     }
    21     }
    22 
    22 
    23     pub fn viewport(&self) -> Rect {
    23     pub fn viewport(&self) -> Rect {
    24         Rect::from_size(self.position, self.size)
    24         #[inline]
       
    25         fn scale(value: usize, zoom: f32) -> i32 {
       
    26             (value as f32 / zoom / 2.0) as i32
       
    27         }
       
    28         let half_width = scale(self.size.width, self.zoom);
       
    29         let half_height = scale(self.size.height, self.zoom);
       
    30         Rect::from_box(
       
    31             self.position.x - half_width,
       
    32             self.position.x + half_width,
       
    33             self.position.y - half_height,
       
    34             self.position.y + half_height,
       
    35         )
    25     }
    36     }
    26 }
    37 }