Skip to main content

beamterm_data/
cell_size.rs

1/// Dimensions of a terminal cell in pixels.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub struct CellSize {
4    pub width: i32,
5    pub height: i32,
6}
7
8impl CellSize {
9    pub fn new(width: i32, height: i32) -> Self {
10        Self { width, height }
11    }
12
13    /// Scales each dimension by the given factor, rounding to the nearest integer.
14    pub fn scale(self, factor: f32) -> Self {
15        Self {
16            width: (self.width as f32 * factor).round() as i32,
17            height: (self.height as f32 * factor).round() as i32,
18        }
19    }
20}