Skip to content

Instantly share code, notes, and snippets.

@harpwood
Last active March 8, 2023 15:21
Show Gist options
  • Save harpwood/8ac37640c0cc359c8d8db6318967257f to your computer and use it in GitHub Desktop.
Save harpwood/8ac37640c0cc359c8d8db6318967257f to your computer and use it in GitHub Desktop.
Returns the diagonal screen size in inches
/**
* Calculates the diagonal length of the display in inches based on the display's width, height, and DPI values.
*
* @returns {number} The diagonal length of the display in inches.
*/
function display_get_diagonal_inches()
{
return sqrt(sqr(display_get_width()) + sqr(display_get_height())) / max(display_get_dpi_x(), display_get_dpi_y());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment