pub struct ContainerViewport {
pub width_px: u32,
pub height_px: u32,
pub dpr_subpx: u32,
pub zoom_subpx: u32,
}Expand description
Container dimensions and display parameters for fit computation.
Represents the available rendering area in physical pixels, plus the DPR and zoom factor needed for correct pixel-to-cell mapping.
Fields§
§width_px: u32Available width in physical pixels.
height_px: u32Available height in physical pixels.
dpr_subpx: u32Device pixel ratio in sub-pixel units (256 = 1.0x DPR).
Must be > 0. Common values:
- 256 = 1.0x (standard density)
- 512 = 2.0x (Retina)
- 768 = 3.0x (high-DPI mobile)
zoom_subpx: u32Zoom factor in sub-pixel units (256 = 100% zoom).
Must be > 0. Common values:
- 256 = 100%
- 320 = 125%
- 384 = 150%
- 512 = 200%
Implementations§
Source§impl ContainerViewport
impl ContainerViewport
Sourcepub fn new(width_px: u32, height_px: u32, dpr: f64, zoom: f64) -> Option<Self>
pub fn new(width_px: u32, height_px: u32, dpr: f64, zoom: f64) -> Option<Self>
Create a viewport with explicit parameters.
Returns None if dimensions are zero or DPR/zoom are zero.
Sourcepub fn simple(width_px: u32, height_px: u32) -> Option<Self>
pub fn simple(width_px: u32, height_px: u32) -> Option<Self>
Create a simple viewport at 1x DPR, 100% zoom.
Sourcepub fn effective_width_subpx(&self) -> u32
pub fn effective_width_subpx(&self) -> u32
Effective pixel width adjusted for DPR and zoom, in sub-pixel units.
Computes physical_px / (dpr * zoom) expressed in the same sub-pixel
units as CellMetrics (1/256 px), so the caller can divide by
cell.width_subpx to get column count.
Sourcepub fn effective_height_subpx(&self) -> u32
pub fn effective_height_subpx(&self) -> u32
Effective pixel height adjusted for DPR and zoom, in sub-pixel units.
Trait Implementations§
Source§impl Clone for ContainerViewport
impl Clone for ContainerViewport
Source§fn clone(&self) -> ContainerViewport
fn clone(&self) -> ContainerViewport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more