A position represented in logical pixels.
For an explanation of what logical pixels are, see description of LogicalSize .
new LogicalPosition (x, y): LogicalPosition
Parameter Type xnumberynumber
LogicalPosition
new LogicalPosition (object): LogicalPosition
Parameter Type objectobjectobject.Logicalobjectobject.Logical.xnumberobject.Logical.ynumber
LogicalPosition
new LogicalPosition (object): LogicalPosition
Parameter Type objectobjectobject.xnumberobject.ynumber
LogicalPosition
Property Modifier Type Default value Defined in typereadonly"Logical"'Logical' xpublicnumberundefined ypublicnumberundefined
__TAURI_TO_IPC_KEY__ (): object
object
Name Type Defined in xnumberynumber
object
Name Type Defined in xnumberynumber
toPhysical (scaleFactor): PhysicalPosition
Converts the logical position to a physical one.
Parameter Type scaleFactornumber
PhysicalPosition
import { LogicalPosition } from ' @crabnebula/taurify-api/dpi ' ;
import { getCurrentWindow } from ' @crabnebula/taurify-api/window ' ;
const appWindow = getCurrentWindow ();
const factor = await appWindow . scaleFactor ();
const position = new LogicalPosition ( 400 , 500 );
const physical = position . toPhysical (factor);
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 .
new LogicalSize (width, height): LogicalSize
Parameter Type widthnumberheightnumber
LogicalSize
new LogicalSize (object): LogicalSize
Parameter Type objectobjectobject.Logicalobjectobject.Logical.heightnumberobject.Logical.widthnumber
LogicalSize
new LogicalSize (object): LogicalSize
Parameter Type objectobjectobject.heightnumberobject.widthnumber
LogicalSize
Property Modifier Type Default value Defined in heightpublicnumberundefined typereadonly"Logical"'Logical' widthpublicnumberundefined
__TAURI_TO_IPC_KEY__ (): object
object
Name Type Defined in heightnumberwidthnumber
object
Name Type Defined in heightnumberwidthnumber
toPhysical (scaleFactor): PhysicalSize
Converts the logical size to a physical one.
Parameter Type scaleFactornumber
PhysicalSize
import { LogicalSize } from ' @crabnebula/taurify-api/dpi ' ;
import { getCurrentWindow } from ' @crabnebula/taurify-api/window ' ;
const appWindow = getCurrentWindow ();
const factor = await appWindow . scaleFactor ();
const size = new LogicalSize ( 400 , 500 );
const physical = size . toPhysical (factor);
A position represented in physical pixels.
For an explanation of what physical pixels are, see description of PhysicalSize .
new PhysicalPosition (x, y): PhysicalPosition
Parameter Type xnumberynumber
PhysicalPosition
new PhysicalPosition (object): PhysicalPosition
Parameter Type objectobjectobject.Physicalobjectobject.Physical.xnumberobject.Physical.ynumber
PhysicalPosition
new PhysicalPosition (object): PhysicalPosition
Parameter Type objectobjectobject.xnumberobject.ynumber
PhysicalPosition
Property Modifier Type Default value Defined in typereadonly"Physical"'Physical' xpublicnumberundefined ypublicnumberundefined
__TAURI_TO_IPC_KEY__ (): object
object
Name Type Defined in xnumberynumber
object
Name Type Defined in xnumberynumber
toLogical (scaleFactor): LogicalPosition
Converts the physical position to a logical one.
Parameter Type scaleFactornumber
LogicalPosition
import { PhysicalPosition } from ' @crabnebula/taurify-api/dpi ' ;
import { getCurrentWindow } from ' @crabnebula/taurify-api/window ' ;
const appWindow = getCurrentWindow ();
const factor = await appWindow . scaleFactor ();
const position = new PhysicalPosition ( 400 , 500 );
const physical = position . toLogical (factor);
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 .
new PhysicalSize (width, height): PhysicalSize
Parameter Type widthnumberheightnumber
PhysicalSize
new PhysicalSize (object): PhysicalSize
Parameter Type objectobjectobject.Physicalobjectobject.Physical.heightnumberobject.Physical.widthnumber
PhysicalSize
new PhysicalSize (object): PhysicalSize
Parameter Type objectobjectobject.heightnumberobject.widthnumber
PhysicalSize
Property Modifier Type Default value Defined in heightpublicnumberundefined typereadonly"Physical"'Physical' widthpublicnumberundefined
__TAURI_TO_IPC_KEY__ (): object
object
Name Type Defined in heightnumberwidthnumber
object
Name Type Defined in heightnumberwidthnumber
toLogical (scaleFactor): LogicalSize
Converts the physical size to a logical one.
Parameter Type scaleFactornumber
LogicalSize
import { getCurrentWindow } from ' @crabnebula/taurify-api/window ' ;
const appWindow = getCurrentWindow ();
const factor = await appWindow . scaleFactor ();
const size = await appWindow . innerSize (); // PhysicalSize
const logical = size . toLogical (factor);
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 ' @crabnebula/taurify-api/core ' ;
import { LogicalPosition, PhysicalPosition } from ' @crabnebula/taurify-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 ' @crabnebula/taurify-api/core ' ;
import { LogicalPosition, PhysicalPosition, Position } from ' @crabnebula/taurify-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 });
new Position (position): Position
Position
__TAURI_TO_IPC_KEY__ (): object
object
object
toLogical (scaleFactor): LogicalPosition
Parameter Type scaleFactornumber
LogicalPosition
toPhysical (scaleFactor): PhysicalPosition
Parameter Type scaleFactornumber
PhysicalPosition
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 ' @crabnebula/taurify-api/core ' ;
import { LogicalSize, PhysicalSize } from ' @crabnebula/taurify-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 ' @crabnebula/taurify-api/core ' ;
import { LogicalSize, PhysicalSize, Size } from ' @crabnebula/taurify-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 });
Size
__TAURI_TO_IPC_KEY__ (): object
object
object
toLogical (scaleFactor): LogicalSize
Parameter Type scaleFactornumber
LogicalSize
toPhysical (scaleFactor): PhysicalSize
Parameter Type scaleFactornumber
PhysicalSize