js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
21 lines (20 loc) • 761 B
JavaScript
import { toRoundedString } from '@js-draw/math';
// @internal
const adjustExportedSVGSize = (svg, exportRect, options) => {
// Adjust the width/height as necessary
let width = exportRect.w;
let height = exportRect.h;
if (options?.minDimension && width < options.minDimension) {
const newWidth = options.minDimension;
height *= newWidth / (width || 1);
width = newWidth;
}
if (options?.minDimension && height < options.minDimension) {
const newHeight = options.minDimension;
width *= newHeight / (height || 1);
height = newHeight;
}
svg.setAttribute('width', toRoundedString(width));
svg.setAttribute('height', toRoundedString(height));
};
export default adjustExportedSVGSize;