Size
Module @netwiv/api/dpi · Kind Class
import { Size } from '@netwiv/api/dpi';A size represented either in physical or in logical pixels.
This type is basically a union type of {@linkcode LogicalSize} and {@linkcode 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 '@netwiv/api/core';import { LogicalSize, PhysicalSize } from '@netwiv/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 {@linkcode Size}
import { invoke } from '@netwiv/api/core';import { LogicalSize, PhysicalSize, Size } from '@netwiv/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 });Constructor
Section titled “Constructor”new Size(size: LogicalSize | PhysicalSize)Instance members
Section titled “Instance members”size: LogicalSize | PhysicalSizetoJSON
Section titled “toJSON”toJSON(): { [x: string]: { width: number; height: number; }; }toLogical
Section titled “toLogical”toLogical(scaleFactor: number): LogicalSizetoPhysical
Section titled “toPhysical”toPhysical(scaleFactor: number): PhysicalSizeUpstream since 2.1.0
Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.