dpi
Classes
Section titled “Classes”LogicalPosition
Section titled “LogicalPosition”A position represented in logical pixels.
For an explanation of what logical pixels are, see description of LogicalSize.
2.0.0
Constructors
Section titled “Constructors”new LogicalPosition()
Section titled “new LogicalPosition()”new LogicalPosition(x, y): LogicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Source: undefined
new LogicalPosition()
Section titled “new LogicalPosition()”new LogicalPosition(object): LogicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.Logical |
object |
object.Logical.x |
number |
object.Logical.y |
number |
Returns
Section titled “Returns”Source: undefined
new LogicalPosition()
Section titled “new LogicalPosition()”new LogicalPosition(object): LogicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “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
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: undefined |
y |
number |
Source: undefined |
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: undefined |
y |
number |
Source: undefined |
Source: undefined
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPositionConverts the logical position to a physical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “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);2.0.0
Source: undefined
LogicalSize
Section titled “LogicalSize”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
Constructors
Section titled “Constructors”new LogicalSize()
Section titled “new LogicalSize()”new LogicalSize(width, height): LogicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Source: undefined
new LogicalSize()
Section titled “new LogicalSize()”new LogicalSize(object): LogicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.Logical |
object |
object.Logical.height |
number |
object.Logical.width |
number |
Returns
Section titled “Returns”Source: undefined
new LogicalSize()
Section titled “new LogicalSize()”new LogicalSize(object): LogicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “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
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: undefined |
width |
number |
Source: undefined |
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: undefined |
width |
number |
Source: undefined |
Source: undefined
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSizeConverts the logical size to a physical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “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);2.0.0
Source: undefined
PhysicalPosition
Section titled “PhysicalPosition”A position represented in physical pixels.
For an explanation of what physical pixels are, see description of PhysicalSize.
2.0.0
Constructors
Section titled “Constructors”new PhysicalPosition()
Section titled “new PhysicalPosition()”new PhysicalPosition(x, y): PhysicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Source: undefined
new PhysicalPosition()
Section titled “new PhysicalPosition()”new PhysicalPosition(object): PhysicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.Physical |
object |
object.Physical.x |
number |
object.Physical.y |
number |
Returns
Section titled “Returns”Source: undefined
new PhysicalPosition()
Section titled “new PhysicalPosition()”new PhysicalPosition(object): PhysicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “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
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: undefined |
y |
number |
Source: undefined |
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: undefined |
y |
number |
Source: undefined |
Source: undefined
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPositionConverts the physical position to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “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);2.0.0
Source: undefined
PhysicalSize
Section titled “PhysicalSize”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
Constructors
Section titled “Constructors”new PhysicalSize()
Section titled “new PhysicalSize()”new PhysicalSize(width, height): PhysicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Source: undefined
new PhysicalSize()
Section titled “new PhysicalSize()”new PhysicalSize(object): PhysicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.Physical |
object |
object.Physical.height |
number |
object.Physical.width |
number |
Returns
Section titled “Returns”Source: undefined
new PhysicalSize()
Section titled “new PhysicalSize()”new PhysicalSize(object): PhysicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
object |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “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
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: undefined |
width |
number |
Source: undefined |
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: undefined |
width |
number |
Source: undefined |
Source: undefined
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSizeConverts the physical size to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “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
Section titled “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 });2.1.0
Constructors
Section titled “Constructors”new Position()
Section titled “new Position()”new Position(position): PositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
position |
LogicalPosition | PhysicalPosition |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
position |
LogicalPosition | PhysicalPosition |
Source: undefined |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
Source: undefined
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Source: undefined
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPositionParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”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
Constructors
Section titled “Constructors”new Size()
Section titled “new Size()”new Size(size): SizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
size |
LogicalSize | PhysicalSize |
Returns
Section titled “Returns”Source: undefined
Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
size |
LogicalSize | PhysicalSize |
Source: undefined |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): objectReturns
Section titled “Returns”object
Source: undefined
toJSON()
Section titled “toJSON()”toJSON(): objectReturns
Section titled “Returns”object
Source: undefined
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Source: undefined
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSizeParameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Source: undefined
Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站