Last active
April 22, 2020 11:06
-
-
Save Nuhvi/d553ab63c0d95aa99283b91cf07f6e5c to your computer and use it in GitHub Desktop.
A function I used to calculate the width and height of an object to fit in a parent element, during working on Single Stroke
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 const scaleNeeded = ( | |
src: { w: number; h: number }, | |
trgt: { w: number; h: number }, | |
): number => { | |
const wr = trgt.w / src.w; | |
const hr = trgt.h / src.h; | |
return Math.min(wr,hr); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment