mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
21 lines
416 B
JavaScript
21 lines
416 B
JavaScript
function resize(width, height) {
|
|
const aspectRatio = width / height;
|
|
|
|
let optimalWidth = Math.round(aspectRatio * 20 * (27 / 3));
|
|
let optimalHeight = 20;
|
|
|
|
if (optimalWidth > 320) {
|
|
const reduction = optimalWidth / 320;
|
|
|
|
optimalWidth = 320;
|
|
|
|
optimalHeight *= reduction;
|
|
}
|
|
|
|
return {
|
|
width: Math.floor(optimalWidth),
|
|
height: Math.floor(optimalHeight),
|
|
};
|
|
}
|
|
|
|
module.exports = {resize};
|