콘텐츠로 이동

LogicalSize

이 콘텐츠는 아직 번역되지 않았습니다.

Module @netwiv/api/dpi · Kind Class

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

A size represented in logical pixels. Logical pixels are scaled according to the window’s DPI scale. Most browser APIs (i.e. MouseEvent’s clientX) will return logical pixels.

For logical-pixel-based position, see {@linkcode LogicalPosition}.

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

Converts the logical size to a physical one.

Example

import { LogicalSize } from '@netwiv/api/dpi';
import { getCurrentWindow } from '@netwiv/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = new LogicalSize(400, 500);
const physical = size.toPhysical(factor);
readonly type: "Logical"
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.