Skip to content
Tauri
Releases

dpi

Classes

LogicalPosition

A position represented in logical pixels.

Since

2.0.0

Constructors

new LogicalPosition()
new LogicalPosition(x, y): LogicalPosition
Parameters
ParameterType
xnumber
ynumber
Returns

LogicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L62

Properties

PropertyTypeDefault value
typestring'Logical'
xnumberundefined
ynumberundefined

LogicalSize

A size represented in logical pixels.

Since

2.0.0

Constructors

new LogicalSize()
new LogicalSize(width, height): LogicalSize
Parameters
ParameterType
widthnumber
heightnumber
Returns

LogicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L15

Properties

PropertyTypeDefault value
heightnumberundefined
typestring'Logical'
widthnumberundefined

PhysicalPosition

A position represented in physical pixels.

Since

2.0.0

Constructors

new PhysicalPosition()
new PhysicalPosition(x, y): PhysicalPosition
Parameters
ParameterType
xnumber
ynumber
Returns

PhysicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L78

Properties

PropertyTypeDefault value
typestring'Physical'
xnumberundefined
ynumberundefined

Methods

toLogical()
toLogical(scaleFactor): LogicalPosition

Converts the physical position to a logical one.

Parameters
ParameterType
scaleFactornumber
Returns

LogicalPosition

Example
import { getCurrent } from '@tauri-apps/api/window';
const appWindow = getCurrent();
const factor = await appWindow.scaleFactor();
const position = await appWindow.innerPosition();
const logical = position.toLogical(factor);

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L94


PhysicalSize

A size represented in physical pixels.

Since

2.0.0

Constructors

new PhysicalSize()
new PhysicalSize(width, height): PhysicalSize
Parameters
ParameterType
widthnumber
heightnumber
Returns

PhysicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L31

Properties

PropertyTypeDefault value
heightnumberundefined
typestring'Physical'
widthnumberundefined

Methods

toLogical()
toLogical(scaleFactor): LogicalSize

Converts the physical size to a logical one.

Parameters
ParameterType
scaleFactornumber
Returns

LogicalSize

Example
import { getCurrent } from '@tauri-apps/api/window';
const appWindow = getCurrent();
const factor = await appWindow.scaleFactor();
const size = await appWindow.innerSize();
const logical = size.toLogical(factor);

Source: https://github.com/tauri-apps/tauri/blob/dev/tooling/api/src/dpi.ts#L47


© 2024 Tauri Contributors. CC-BY / MIT