love.window.toPixels

Available since LÖVE 0.9.2
This function is not supported in earlier versions.

Converts a number from density-independent units to pixels.

If the highdpi window flag is enabled in Mac OS X and the window is in a retina screen, density-independent units will be twice the size of pixels. Otherwise they will usually be the same. This function can be used to convert coordinates from the size users are expecting them to display at onscreen to pixels. love.window.fromPixels does the opposite.

Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units.

Function

Synopsis

pixelvalue = love.window.toPixels( value )

Arguments

number value
A number in density-independent units to convert to pixels.

Returns

number pixelvalue
The converted number, in pixels.

Function

Synopsis

px, py = love.window.toPixels( x, y )

Arguments

number x
The x-axis value of a coordinate in density-independent units to convert to pixels.
number y
The y-axis value of a coordinate in density-independent units to convert to pixels.

Returns

number px
The converted x-axis value of the coordinate, in pixels.
number py
The converted y-axis value of the coordinate, in pixels.

Notes

The units of love.graphics.getWidth, love.graphics.getHeight, love.mouse.getPosition, and mouse events are always in terms of pixels.

See Also

Other Languages