Skip to content

PhysicalSize

Module @netwiv/api/dpi · Kind Class

import { PhysicalSize } from '@netwiv/api/dpi';

A size represented in physical pixels.

Physical pixels represent actual screen pixels, and are DPI-independent. For high-DPI windows, this means that any point in the window on the screen will have a different position in logical pixels {@linkcode LogicalSize}.

For physical-pixel-based position, see {@linkcode PhysicalPosition}.

new PhysicalSize(width: number, height: number)
new PhysicalSize(object: { Physical: { width: number; height: number; }; })
new PhysicalSize(object: { width: number; height: number; })
height: number
toJSON(): { width: number; height: number; }
toLogical(scaleFactor: number): LogicalSize

Converts the physical size to a logical one.

Example

import { getCurrentWindow } from '@netwiv/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = await appWindow.innerSize(); // PhysicalSize
const logical = size.toLogical(factor);
readonly type: "Physical"
width: number

Upstream since 2.0.0


Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.