Created
March 8, 2023 15:24
-
-
Save harpwood/ff6429eb9b6e4481dd5d4ae50140cee4 to your computer and use it in GitHub Desktop.
Converts a length in centimeters to the equivalent length in pixels, based on the current display's DPI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a length in centimeters to the equivalent length in pixels, based on the current display's DPI. | |
* @param {number} cm - The length in centimeters 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_centimeters_to_pixel(cm) { | |
return max(display_get_dpi_x(), display_get_dpi_y()) * cm / 2.54; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment