Skip to content

Instantly share code, notes, and snippets.

@klzns
Created December 20, 2021 14:58
Show Gist options
  • Save klzns/add05c229677a3a8e90928d47798097f to your computer and use it in GitHub Desktop.
Save klzns/add05c229677a3a8e90928d47798097f to your computer and use it in GitHub Desktop.
px to cm - cm to px
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