natiny.window.get_scale
natiny.window.get_scale(win)
Returns the display scaling factor captured when the window was created.
Parameters
| Name | Type | Description |
|---|---|---|
win |
number |
Window handle from natiny.window.create |
Returns
| Type | Description |
|---|---|
number |
Display scale: 1 for 100%, 1.5 for 150%, 2 for 200%, or 0 if the window does not exist |
Example
Manual display scaling in the default pixel-for-pixel mode:
local win = natiny.window.create("My Game", 1280, 720)
local s = natiny.window.get_scale(win)
local font = natiny.font.create(ttf, 16 * s)
natiny.render.text(font, 20 * s, 20 * s, "hello")
Notes
SCALE_MODE_STRETCHandSCALE_MODE_HIDPIapply this factor automatically.SCALE_MODE_PIXELSignores it.- The value is captured when the window is created. Moving the window to another display does not update it.
- This function only reads the factor; it does not change the window's mode.