Skip to content
Tauri 中文网

dpi

A position represented in logical pixels. For an explanation of what logical pixels are, see description of LogicalSize.

2.0.0

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

LogicalPosition

Source: undefined

new LogicalPosition(object): LogicalPosition
ParameterType
objectobject
object.Logicalobject
object.Logical.xnumber
object.Logical.ynumber

LogicalPosition

Source: undefined

new LogicalPosition(object): LogicalPosition
ParameterType
objectobject
object.xnumber
object.ynumber

LogicalPosition

Source: undefined

PropertyModifierTypeDefault valueDefined in
typereadonly"Logical"'Logical'Source: undefined
xpublicnumberundefinedSource: undefined
ypublicnumberundefinedSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
xnumberSource: undefined
ynumberSource: undefined

Source: undefined

toJSON(): object

object

NameTypeDefined in
xnumberSource: undefined
ynumberSource: undefined

Source: undefined

toPhysical(scaleFactor): PhysicalPosition

Converts the logical position to a physical one.

ParameterType
scaleFactornumber

PhysicalPosition

import { LogicalPosition } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const position = new LogicalPosition(400, 500);
const physical = position.toPhysical(factor);

2.0.0

Source: undefined


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 LogicalPosition.

2.0.0

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

LogicalSize

Source: undefined

new LogicalSize(object): LogicalSize
ParameterType
objectobject
object.Logicalobject
object.Logical.heightnumber
object.Logical.widthnumber

LogicalSize

Source: undefined

new LogicalSize(object): LogicalSize
ParameterType
objectobject
object.heightnumber
object.widthnumber

LogicalSize

Source: undefined

PropertyModifierTypeDefault valueDefined in
heightpublicnumberundefinedSource: undefined
typereadonly"Logical"'Logical'Source: undefined
widthpublicnumberundefinedSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
heightnumberSource: undefined
widthnumberSource: undefined

Source: undefined

toJSON(): object

object

NameTypeDefined in
heightnumberSource: undefined
widthnumberSource: undefined

Source: undefined

toPhysical(scaleFactor): PhysicalSize

Converts the logical size to a physical one.

ParameterType
scaleFactornumber

PhysicalSize

import { LogicalSize } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = new LogicalSize(400, 500);
const physical = size.toPhysical(factor);

2.0.0

Source: undefined


A position represented in physical pixels.

For an explanation of what physical pixels are, see description of PhysicalSize.

2.0.0

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

PhysicalPosition

Source: undefined

new PhysicalPosition(object): PhysicalPosition
ParameterType
objectobject
object.Physicalobject
object.Physical.xnumber
object.Physical.ynumber

PhysicalPosition

Source: undefined

new PhysicalPosition(object): PhysicalPosition
ParameterType
objectobject
object.xnumber
object.ynumber

PhysicalPosition

Source: undefined

PropertyModifierTypeDefault valueDefined in
typereadonly"Physical"'Physical'Source: undefined
xpublicnumberundefinedSource: undefined
ypublicnumberundefinedSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
xnumberSource: undefined
ynumberSource: undefined

Source: undefined

toJSON(): object

object

NameTypeDefined in
xnumberSource: undefined
ynumberSource: undefined

Source: undefined

toLogical(scaleFactor): LogicalPosition

Converts the physical position to a logical one.

ParameterType
scaleFactornumber

LogicalPosition

import { PhysicalPosition } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const position = new PhysicalPosition(400, 500);
const physical = position.toLogical(factor);

2.0.0

Source: undefined


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 PhysicalPosition.

2.0.0

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

PhysicalSize

Source: undefined

new PhysicalSize(object): PhysicalSize
ParameterType
objectobject
object.Physicalobject
object.Physical.heightnumber
object.Physical.widthnumber

PhysicalSize

Source: undefined

new PhysicalSize(object): PhysicalSize
ParameterType
objectobject
object.heightnumber
object.widthnumber

PhysicalSize

Source: undefined

PropertyModifierTypeDefault valueDefined in
heightpublicnumberundefinedSource: undefined
typereadonly"Physical"'Physical'Source: undefined
widthpublicnumberundefinedSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
heightnumberSource: undefined
widthnumberSource: undefined

Source: undefined

toJSON(): object

object

NameTypeDefined in
heightnumberSource: undefined
widthnumberSource: undefined

Source: undefined

toLogical(scaleFactor): LogicalSize

Converts the physical size to a logical one.

ParameterType
scaleFactornumber

LogicalSize

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

Source: undefined


A position represented either in physical or in logical pixels.

This type is basically a union type of LogicalSize and PhysicalSize but comes in handy when using tauri::Position in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into tauri::Position

So instead of

import { invoke } from '@tauri-apps/api/core';
import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
const validPosition = position instanceof LogicalPosition
? { Logical: { x: position.x, y: position.y } }
: { Physical: { x: position.x, y: position.y } }
await invoke("do_something_with_position", { position: validPosition });

You can just use Position

import { invoke } from '@tauri-apps/api/core';
import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
const validPosition = new Position(position);
await invoke("do_something_with_position", { position: validPosition });

2.1.0

new Position(position): Position
ParameterType
positionLogicalPosition | PhysicalPosition

Position

Source: undefined

PropertyTypeDefined in
positionLogicalPosition | PhysicalPositionSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

Source: undefined

toJSON(): object

object

Source: undefined

toLogical(scaleFactor): LogicalPosition
ParameterType
scaleFactornumber

LogicalPosition

Source: undefined

toPhysical(scaleFactor): PhysicalPosition
ParameterType
scaleFactornumber

PhysicalPosition

Source: undefined


A size represented either in physical or in logical pixels.

This type is basically a union type of LogicalSize and PhysicalSize but comes in handy when using tauri::Size in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into tauri::Size

So instead of

import { invoke } from '@tauri-apps/api/core';
import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
const validSize = size instanceof LogicalSize
? { Logical: { width: size.width, height: size.height } }
: { Physical: { width: size.width, height: size.height } }
await invoke("do_something_with_size", { size: validSize });

You can just use Size

import { invoke } from '@tauri-apps/api/core';
import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
const validSize = new Size(size);
await invoke("do_something_with_size", { size: validSize });

2.1.0

new Size(size): Size
ParameterType
sizeLogicalSize | PhysicalSize

Size

Source: undefined

PropertyTypeDefined in
sizeLogicalSize | PhysicalSizeSource: undefined

__TAURI_TO_IPC_KEY__(): object

object

Source: undefined

toJSON(): object

object

Source: undefined

toLogical(scaleFactor): LogicalSize
ParameterType
scaleFactornumber

LogicalSize

Source: undefined

toPhysical(scaleFactor): PhysicalSize
ParameterType
scaleFactornumber

PhysicalSize

Source: undefined


Tauri v2.8 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站