콘텐츠로 이동

PhysicalPosition

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

Module @netwiv/api/dpi · Kind Class

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

A position represented in physical pixels.

For an explanation of what physical pixels are, see description of {@linkcode PhysicalSize}.

new PhysicalPosition(x: number, y: number)
new PhysicalPosition(object: { Physical: { x: number; y: number; }; })
new PhysicalPosition(object: { x: number; y: number; })
toJSON(): { x: number; y: number; }
toLogical(scaleFactor: number): LogicalPosition

Converts the physical position to a logical one.

Example

import { PhysicalPosition } from '@netwiv/api/dpi';
import { getCurrentWindow } from '@netwiv/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const position = new PhysicalPosition(400, 500);
const physical = position.toLogical(factor);
readonly type: "Physical"
x: number
y: 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.