Difference between revisions of "love.window.getDPIScale"

(I coppied the love.window.getPixelScale wiki page in here and replaced the name)
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{newin|[[0.11.0]]|110|type=function|text=This function replaces [[love.window.getPixelScale]]}}
+
{{newin|[[11.0]]|110|type=function|text=This function replaces [[love.window.getPixelScale]]}}
 
Gets the DPI scale factor associated with the window.
 
Gets the DPI scale factor associated with the window.
  
Line 19: Line 19:
  
 
== Notes ==
 
== Notes ==
The units of [[love.graphics.getWidth]], [[love.graphics.getHeight]], [[love.mouse.getPosition]], mouse events, [[love.touch.getPosition]], and touch events are always in terms of pixels.
+
The units of [[love.graphics.getWidth]], [[love.graphics.getHeight]], [[love.mouse.getPosition]], mouse events, [[love.touch.getPosition]], and touch events are always in DPI-scaled units in LOVE [[11.0]]+, unless the <code>usedpiscale</code> flag is set to false in [[love.window.setMode]] or [[love.conf]].
  
 
== See Also ==
 
== See Also ==

Latest revision as of 21:35, 29 February 2020

Available since LÖVE 11.0
This function replaces love.window.getPixelScale.

Gets the DPI scale factor associated with the window.

The pixel density inside the window might be greater (or smaller) than the "size" of the window. For example on a retina screen in Mac OS X with the highdpi window flag enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. love.window.getDPIScale() would return 2.0 in that case.

The love.window.fromPixels and love.window.toPixels functions can also be used to convert between units.

The highdpi window flag must be enabled to use the full pixel density of a Retina screen on Mac OS X and iOS. The flag currently does nothing on Windows and Linux, and on Android it is effectively always enabled.

Function

Synopsis

scale = love.window.getDPIScale( )

Arguments

None.

Returns

number scale
The pixel scale factor associated with the window.

Notes

The units of love.graphics.getWidth, love.graphics.getHeight, love.mouse.getPosition, mouse events, love.touch.getPosition, and touch events are always in DPI-scaled units in LOVE 11.0+, unless the usedpiscale flag is set to false in love.window.setMode or love.conf.

See Also

Other Languages