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| Parameter | Type |
|---|---|
x | number |
y | number |
Source: undefined
new LogicalPosition(object): LogicalPosition| Parameter | Type |
|---|---|
object | object |
object.Logical | object |
object.Logical.x | number |
object.Logical.y | number |
Source: undefined
new LogicalPosition(object): LogicalPosition| Parameter | Type |
|---|---|
object | object |
object.x | number |
object.y | number |
Source: undefined
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type | readonly | "Logical" | 'Logical' | Source: undefined |
x | public | number | undefined | Source: undefined |
y | public | number | undefined | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
| Name | Type | Defined in |
|---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toJSON(): objectobject
| Name | Type | Defined in |
|---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toPhysical(scaleFactor): PhysicalPositionConverts the logical position to a physical one.
| Parameter | Type |
|---|---|
scaleFactor | number |
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| Parameter | Type |
|---|---|
width | number |
height | number |
Source: undefined
new LogicalSize(object): LogicalSize| Parameter | Type |
|---|---|
object | object |
object.Logical | object |
object.Logical.height | number |
object.Logical.width | number |
Source: undefined
new LogicalSize(object): LogicalSize| Parameter | Type |
|---|---|
object | object |
object.height | number |
object.width | number |
Source: undefined
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height | public | number | undefined | Source: undefined |
type | readonly | "Logical" | 'Logical' | Source: undefined |
width | public | number | undefined | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
| Name | Type | Defined in |
|---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toJSON(): objectobject
| Name | Type | Defined in |
|---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toPhysical(scaleFactor): PhysicalSizeConverts the logical size to a physical one.
| Parameter | Type |
|---|---|
scaleFactor | number |
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| Parameter | Type |
|---|---|
x | number |
y | number |
Source: undefined
new PhysicalPosition(object): PhysicalPosition| Parameter | Type |
|---|---|
object | object |
object.Physical | object |
object.Physical.x | number |
object.Physical.y | number |
Source: undefined
new PhysicalPosition(object): PhysicalPosition| Parameter | Type |
|---|---|
object | object |
object.x | number |
object.y | number |
Source: undefined
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type | readonly | "Physical" | 'Physical' | Source: undefined |
x | public | number | undefined | Source: undefined |
y | public | number | undefined | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
| Name | Type | Defined in |
|---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toJSON(): objectobject
| Name | Type | Defined in |
|---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toLogical(scaleFactor): LogicalPositionConverts the physical position to a logical one.
| Parameter | Type |
|---|---|
scaleFactor | number |
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 LogicalSize.
For physical-pixel-based position, see PhysicalPosition.
2.0.0
new PhysicalSize(width, height): PhysicalSize| Parameter | Type |
|---|---|
width | number |
height | number |
Source: undefined
new PhysicalSize(object): PhysicalSize| Parameter | Type |
|---|---|
object | object |
object.Physical | object |
object.Physical.height | number |
object.Physical.width | number |
Source: undefined
new PhysicalSize(object): PhysicalSize| Parameter | Type |
|---|---|
object | object |
object.height | number |
object.width | number |
Source: undefined
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height | public | number | undefined | Source: undefined |
type | readonly | "Physical" | 'Physical' | Source: undefined |
width | public | number | undefined | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
| Name | Type | Defined in |
|---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toJSON(): objectobject
| Name | Type | Defined in |
|---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toLogical(scaleFactor): LogicalSizeConverts the physical size to a logical one.
| Parameter | Type |
|---|---|
scaleFactor | number |
import { getCurrentWindow } from '@tauri-apps/api/window';const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = await appWindow.innerSize(); // PhysicalSizeconst 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 PhysicalPositionconst 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 PhysicalPositionconst validPosition = new Position(position);await invoke("do_something_with_position", { position: validPosition });2.1.0
new Position(position): Position| Parameter | Type |
|---|---|
position | LogicalPosition | PhysicalPosition |
Source: undefined
| Property | Type | Defined in |
|---|---|---|
position | LogicalPosition | PhysicalPosition | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
Source: undefined
toJSON(): objectobject
Source: undefined
toLogical(scaleFactor): LogicalPosition| Parameter | Type |
|---|---|
scaleFactor | number |
Source: undefined
toPhysical(scaleFactor): PhysicalPosition| Parameter | Type |
|---|---|
scaleFactor | number |
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 PhysicalSizeconst 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 PhysicalSizeconst validSize = new Size(size);await invoke("do_something_with_size", { size: validSize });2.1.0
new Size(size): Size| Parameter | Type |
|---|---|
size | LogicalSize | PhysicalSize |
Source: undefined
| Property | Type | Defined in |
|---|---|---|
size | LogicalSize | PhysicalSize | Source: undefined |
__TAURI_TO_IPC_KEY__(): objectobject
Source: undefined
toJSON(): objectobject
Source: undefined
toLogical(scaleFactor): LogicalSize| Parameter | Type |
|---|---|
scaleFactor | number |
Source: undefined
toPhysical(scaleFactor): PhysicalSize| Parameter | Type |
|---|---|
scaleFactor | number |
Source: undefined
Tauri v2.9 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站