Revision Difference
Global.ScreenScale#562818
<function name="ScreenScale" parent="Global" type="libraryfunc">
<description>Returns a number based on the `size` argument and the players' screen width. The width is scaled in relation to `640x480` resolution. This function is primarily used for scaling font sizes.
<description>Returns a number based on the `size` argument and the players' screen width. This is used to scale user interface (UI) elements to be consistently sized and positioned across all screen resolutions.
⤶
The width is scaled in relation to `640x480` resolution, and does **not** take into account non the aspect ratio. See example below for how to adjust or that.⤶
⤶
This function can also be used for scaling font sizes.⤶
See <page>Global.ScreenScaleH</page> for a function that scales from height.
</description>
<realm>Client</realm>
<file line="6-L8">lua/includes/extensions/client/globals.lua</file>
<args>
<arg name="size" type="number">The number you want to scale.</arg>
<arg name="size" type="number">The position or size you want to scale within 640 pixel wide screen.</arg>
</args>
<rets>
<ret name="" type="number">The scaled number based on your screen's width</ret>⤶
<ret name="" type="number">The scaled number based on the player's screen width.</ret>⤶
</rets>
</function>
<example>
<description>Prints a scaled number based on the number 96, 400 and 640.</description>
<code>
print( ScreenScale( 96 ) )
print( ScreenScale( 400 ) )
print( ScreenScale( 640 ) )
</code>
<output>252, 1050, 1680 (this will differ depending on your screen width. Here the screen width is 1680.)</output>
⤶
</example>⤶
</example>⤶
⤶
<example>⤶
<description>Adjust for non 4:3 aspect ratios.</description>⤶
<code>⤶
print( ScreenScale( 96 ) / ( ScrW() / ScrH() ) )⤶
</code>⤶
</example>