Available since LÖVE 0.9.2
This function is not supported in earlier versions.
Converts a number from pixels to density-independent units.
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.fromPixels(1600) would return
800 in that case.
This function converts coordinates from pixels to the size users are expecting them to display at onscreen. love.window.toPixels does the opposite. 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.
Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units.
value = love.window.fromPixels( pixelvalue )
x, y = love.window.fromPixels( px, py )
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.
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.