bigbluebutton-Github/bigbluebutton-html5/imports/api/slides/server/helpers.js
2023-02-14 13:27:51 -03:00

28 lines
758 B
JavaScript
Executable File

const calculateSlideData = (slideData) => {
const {
width, height, xOffset, yOffset, widthRatio, heightRatio,
} = slideData;
// calculating viewBox and offsets for the current presentation
const maxImageWidth = 2048;
const maxImageHeight = 1536;
const ratio = Math.min(maxImageWidth / width, maxImageHeight / height);
const scaledWidth = width * ratio;
const scaledHeight = height * ratio;
const scaledViewBoxWidth = width * widthRatio / 100 * ratio;
const scaledViewBoxHeight = height * heightRatio / 100 * ratio;
return {
width: scaledWidth,
height: scaledHeight,
x: xOffset,
y: yOffset,
viewBoxWidth: scaledViewBoxWidth,
viewBoxHeight: scaledViewBoxHeight,
};
};
export default calculateSlideData;