[0.16.51] Style.width/height is incorret.

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[0.16.51] Style.width/height is incorret.

Post by eradicator »

What
Applying LuaGuiElement.style.height/width = 128 for example does not make a 128x128 element.
not128.png
not128.png (99.37 KiB) Viewed 1689 times
Reproduce

Code: Select all

/c
game.player.gui.center.clear()
x = game.player.gui.center.add{type='frame'}
x.style.width = 128
x.style.height=128
At standard zoom (F9) the problem is quite obvious even in the in-game grid. Though i discovered it by measuring pixels on a screenshot. The deviation seems to depend on the size of factorios game window.

Why?
I'm trying to get a screen-sized window but using display_resolution makes it larger than the screen.

Code: Select all

/c
game.player.gui.center.clear()
x = game.player.gui.center.add{type='frame'}
x.style.width = game.player.display_resolution.width
x.style.height=game.player.display_resolution.height
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.16.51] Style.width/height is incorret.

Post by Bilka »

Is your gui scale set to 1 and your resolution 720p? Only then the width/height is actually 1:1 the pixel width/height, otherwise it's not.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.51] Style.width/height is incorret.

Post by eradicator »

Bilka wrote:
Fri Nov 09, 2018 12:49 pm
Is your gui scale set to 1 and your resolution 720p? Only then the width/height is actually 1:1 the pixel width/height, otherwise it's not.
Scale 1 yes, 720p..no? Who plays at 720p in this age. And the point is that display_resolution is meaningless if i can't use it to make precisely sized windows.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.16.51] Style.width/height is incorret.

Post by Klonan »

It does some internal hidden scaling, which is removed for 0.17.

Until then, you can disable the auto scaling by setting:
https://lua-api.factorio.com/latest/Lua ... .scaleable
to false

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.51] Style.width/height is incorret.

Post by eradicator »

Klonan wrote:
Fri Nov 09, 2018 1:04 pm
It does some internal hidden scaling, which is removed for 0.17.

Until then, you can disable the auto scaling by setting:
https://lua-api.factorio.com/latest/Lua ... .scaleable
to false
That seems to work. Thank you. This was quite frustrating.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.51] Style.width/height is incorret.

Post by eradicator »

Klonan wrote:
Fri Nov 09, 2018 1:04 pm
It does some internal hidden scaling, which is removed for 0.17.
Hm...can you please post the source for the scaling (or the formula)?
It looks like i might need to mimick it to get the elements precisely the size i want (i.e. the size of the vanilla gui elements next to it).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Resolved Problems and Bugs”