Created
November 20, 2021 18:04
-
-
Save trurl-master/9bf947716c950683f42347ede66f0215 to your computer and use it in GitHub Desktop.
Calculate rotated bounding box size
This file contains hidden or 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 rotateSize(width: number, height: number, rotation: number): { width: number, height: number } { | |
const rotRad = (rotation * Math.PI) / 180 | |
return { | |
width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), | |
height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment