flat assembler
Message board for the users of flat assembler.
Index
> Windows > How calculating GUI pos regarding screen resolution ? |
| Author |
|
|
Roman 22 Oct 2026, 00:18
Neural net say this:
Code: offsetX = 50; GUI element pos offsetY = 100; GUI element pos baseWidth = 1920; baseHeight = 1080; actualOffsetX = offsetX * (screenWidth / baseWidth); actualOffsetY = offsetY * (screenHeight / baseHeight); This is right formula ? |
|||
|
|
frankobach26 22 Oct 2026, 15:08
Hello Roman perhaps this Info can Help
Code: struct Screen { float w, h; }; float sx = screen.w / 1920.0f; float sy = screen.h / 1080.0f; float scale = fminf(sx, sy); // positions: uniform scale keeps proportions btn.x = 50 * scale; btn.y = 100 * scale; // sizes: uniform scale too btn.w = 200 * scale; btn.h = 60 * scale; // full-bleed elements (status bar): stretch to screen statusBar.w = screen.w; the neural net's formula is "right" as a coordinate mapping, but use scale = min(sx, sy) (uniform) for positions and sizes, and use anchoring for elements that should stretch with the window. That gives you a clean 1920×1080 design that works on 1366×768, 1600×768 and 2560×1440 without distortion or cut-off elements |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.