beamterm-data 1.0.0

Core data structures and binary serialization for the beamterm WebGL terminal renderer
Documentation
/// Dimensions of a terminal cell in pixels.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CellSize {
    /// Cell width in pixels.
    pub width: i32,
    /// Cell height in pixels.
    pub height: i32,
}

impl CellSize {
    /// Creates a new cell size with the given width and height in pixels.
    #[must_use]
    pub fn new(width: i32, height: i32) -> Self {
        Self { width, height }
    }

    /// Scales each dimension by the given factor, rounding to the nearest integer.
    #[must_use]
    pub fn scale(self, factor: f32) -> Self {
        Self {
            width: (self.width as f32 * factor).round() as i32,
            height: (self.height as f32 * factor).round() as i32,
        }
    }
}