bigbluebutton-Github/bigbluebutton-html5/imports/api/slides/server/helpers.js

28 lines
758 B
JavaScript
Raw Normal View History

const calculateSlideData = (slideData) => {
const {
width, height, xOffset, yOffset, widthRatio, heightRatio,
} = slideData;
// calculating viewBox and offsets for the current presentation
2023-02-15 00:27:51 +08:00
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 {
2023-02-15 00:27:51 +08:00
width: scaledWidth,
height: scaledHeight,
x: xOffset,
y: yOffset,
2023-02-15 00:27:51 +08:00
viewBoxWidth: scaledViewBoxWidth,
viewBoxHeight: scaledViewBoxHeight,
};
};
export default calculateSlideData;