mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Merge pull request #311 from rigo128/fix_get_screen_aspect_koef
Fix helper.get_screen_aspect_koef() for gui layouts.
This commit is contained in:
commit
9a0f341a67
@ -141,16 +141,23 @@ end
|
|||||||
---@return number stretch_x
|
---@return number stretch_x
|
||||||
---@return number stretch_y
|
---@return number stretch_y
|
||||||
function M.get_screen_aspect_koef()
|
function M.get_screen_aspect_koef()
|
||||||
local window_x, window_y = window.get_size()
|
local gui_width = gui.get_width()
|
||||||
|
local gui_height = gui.get_height()
|
||||||
|
local gui_r = gui_width / gui_height
|
||||||
|
|
||||||
local stretch_x = window_x / gui.get_width()
|
local window_width, window_height = window.get_size()
|
||||||
local stretch_y = window_y / gui.get_height()
|
local window_r = window_width / window_height
|
||||||
local stretch_koef = math.min(stretch_x, stretch_y)
|
|
||||||
|
|
||||||
local koef_x = window_x / (stretch_koef * sys.get_config_int("display.width"))
|
local w_s = 1
|
||||||
local koef_y = window_y / (stretch_koef * sys.get_config_int("display.height"))
|
local h_s = 1
|
||||||
|
|
||||||
return koef_x, koef_y
|
if gui_r < window_r then
|
||||||
|
w_s = window_r / gui_r
|
||||||
|
else
|
||||||
|
h_s = gui_r / window_r
|
||||||
|
end
|
||||||
|
|
||||||
|
return w_s, h_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user