Skip to content

Instantly share code, notes, and snippets.

@harpwood
Last active March 8, 2023 15:22
Show Gist options
  • Save harpwood/b51dfb8c3afcc46e1e3f6f8bf79c828c to your computer and use it in GitHub Desktop.
Save harpwood/b51dfb8c3afcc46e1e3f6f8bf79c828c to your computer and use it in GitHub Desktop.
Converts inches into pixels based the current screen
/**
* Converts a length in inches to the equivalent length in pixels, based on the current display's DPI.
* @param {number} inches - The length in inches to convert to pixels.
* @returns {number} The equivalent length in pixels.
*
* @author Written by Gkri (Harpwood studio)
* @license MIT License https://opensource.org/licenses/MIT
*/
function display_inches_to_pixel(inches) {
return max(display_get_dpi_x(), display_get_dpi_y()) * inches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment