Created
December 20, 2021 14:58
-
-
Save klzns/add05c229677a3a8e90928d47798097f to your computer and use it in GitHub Desktop.
px to cm - cm to px
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
export function convertPxToCm(pixels: number) { | |
return (pixels * 2.54) / (96 * window.devicePixelRatio) | |
} | |
export function convertCmToPx(cm: number) { | |
return (cm * 96) / 2.54 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment