dpi
Classes
LogicalPosition
A position represented in logical pixels.
Since
2.0.0
Constructors
new LogicalPosition()
new LogicalPosition(x, y): LogicalPosition
Parameters
Parameter | Type |
---|---|
x | number |
y | number |
Returns
Source: undefined
new LogicalPosition()
new LogicalPosition(object): LogicalPosition
Parameters
Parameter | Type |
---|---|
object | object |
object.Logical | object |
object.Logical.x | number |
object.Logical.y | number |
Returns
Source: undefined
new LogicalPosition()
new LogicalPosition(object): LogicalPosition
Parameters
Parameter | Type |
---|---|
object | object |
object.x | number |
object.y | number |
Returns
Source: undefined
Properties
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 |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Name | Type | Defined in |
---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toJSON()
toJSON(): object
Returns
object
Name | Type | Defined in |
---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toPhysical()
toPhysical(scaleFactor): PhysicalPosition
Converts the logical position to a physical one.
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Example
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);
Since
2.0.0
Source: undefined
LogicalSize
A size represented in logical pixels.
Since
2.0.0
Constructors
new LogicalSize()
new LogicalSize(width, height): LogicalSize
Parameters
Parameter | Type |
---|---|
width | number |
height | number |
Returns
Source: undefined
new LogicalSize()
new LogicalSize(object): LogicalSize
Parameters
Parameter | Type |
---|---|
object | object |
object.Logical | object |
object.Logical.height | number |
object.Logical.width | number |
Returns
Source: undefined
new LogicalSize()
new LogicalSize(object): LogicalSize
Parameters
Parameter | Type |
---|---|
object | object |
object.height | number |
object.width | number |
Returns
Source: undefined
Properties
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 |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Name | Type | Defined in |
---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toJSON()
toJSON(): object
Returns
object
Name | Type | Defined in |
---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toPhysical()
toPhysical(scaleFactor): PhysicalSize
Converts the logical size to a physical one.
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Example
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);
Since
2.0.0
Source: undefined
PhysicalPosition
A position represented in physical pixels.
Since
2.0.0
Constructors
new PhysicalPosition()
new PhysicalPosition(x, y): PhysicalPosition
Parameters
Parameter | Type |
---|---|
x | number |
y | number |
Returns
Source: undefined
new PhysicalPosition()
new PhysicalPosition(object): PhysicalPosition
Parameters
Parameter | Type |
---|---|
object | object |
object.Physical | object |
object.Physical.x | number |
object.Physical.y | number |
Returns
Source: undefined
new PhysicalPosition()
new PhysicalPosition(object): PhysicalPosition
Parameters
Parameter | Type |
---|---|
object | object |
object.x | number |
object.y | number |
Returns
Source: undefined
Properties
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 |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Name | Type | Defined in |
---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toJSON()
toJSON(): object
Returns
object
Name | Type | Defined in |
---|---|---|
x | number | Source: undefined |
y | number | Source: undefined |
Source: undefined
toLogical()
toLogical(scaleFactor): LogicalPosition
Converts the physical position to a logical one.
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Example
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);
Since
2.0.0
Source: undefined
PhysicalSize
A size represented in physical pixels.
Since
2.0.0
Constructors
new PhysicalSize()
new PhysicalSize(width, height): PhysicalSize
Parameters
Parameter | Type |
---|---|
width | number |
height | number |
Returns
Source: undefined
new PhysicalSize()
new PhysicalSize(object): PhysicalSize
Parameters
Parameter | Type |
---|---|
object | object |
object.Physical | object |
object.Physical.height | number |
object.Physical.width | number |
Returns
Source: undefined
new PhysicalSize()
new PhysicalSize(object): PhysicalSize
Parameters
Parameter | Type |
---|---|
object | object |
object.height | number |
object.width | number |
Returns
Source: undefined
Properties
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 |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Name | Type | Defined in |
---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toJSON()
toJSON(): object
Returns
object
Name | Type | Defined in |
---|---|---|
height | number | Source: undefined |
width | number | Source: undefined |
Source: undefined
toLogical()
toLogical(scaleFactor): LogicalSize
Converts the physical size to a logical one.
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Example
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
Position
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 });
Since
2.1.0
Constructors
new Position()
new Position(position): Position
Parameters
Parameter | Type |
---|---|
position | LogicalPosition | PhysicalPosition |
Returns
Source: undefined
Properties
Property | Type | Defined in |
---|---|---|
position | LogicalPosition | PhysicalPosition | Source: undefined |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Source: undefined
toJSON()
toJSON(): object
Returns
object
Source: undefined
toLogical()
toLogical(scaleFactor): LogicalPosition
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Source: undefined
toPhysical()
toPhysical(scaleFactor): PhysicalPosition
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Source: undefined
Size
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 });
Since
2.1.0
Constructors
new Size()
new Size(size): Size
Parameters
Parameter | Type |
---|---|
size | LogicalSize | PhysicalSize |
Returns
Source: undefined
Properties
Property | Type | Defined in |
---|---|---|
size | LogicalSize | PhysicalSize | Source: undefined |
Methods
__TAURI_TO_IPC_KEY__()
__TAURI_TO_IPC_KEY__(): object
Returns
object
Source: undefined
toJSON()
toJSON(): object
Returns
object
Source: undefined
toLogical()
toLogical(scaleFactor): LogicalSize
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Source: undefined
toPhysical()
toPhysical(scaleFactor): PhysicalSize
Parameters
Parameter | Type |
---|---|
scaleFactor | number |
Returns
Source: undefined
Tauri 中文网 - 粤ICP备13048890号