mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
chore: unite usage of normalizedCanvasDimensions and canvasDimensions
This commit is contained in:
parent
95baf540f2
commit
97ff1222d9
1 changed files with 20 additions and 19 deletions
|
@ -302,13 +302,13 @@ const addContentBackgroundToSvg = ({
|
||||||
svgRoot,
|
svgRoot,
|
||||||
contentSize,
|
contentSize,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
dimensions,
|
canvasDimensions,
|
||||||
includeLogo,
|
includeLogo,
|
||||||
}: {
|
}: {
|
||||||
svgRoot: SVGSVGElement;
|
svgRoot: SVGSVGElement;
|
||||||
contentSize: Dimensions;
|
contentSize: Dimensions;
|
||||||
backgroundColor: string;
|
backgroundColor: string;
|
||||||
dimensions: Dimensions;
|
canvasDimensions: Dimensions;
|
||||||
includeLogo: boolean;
|
includeLogo: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
// Create the shadow filter
|
// Create the shadow filter
|
||||||
|
@ -366,7 +366,7 @@ const addContentBackgroundToSvg = ({
|
||||||
// Solid color background
|
// Solid color background
|
||||||
const { x, y, width, height } = getContentBackgound(
|
const { x, y, width, height } = getContentBackgound(
|
||||||
contentSize,
|
contentSize,
|
||||||
dimensions,
|
canvasDimensions,
|
||||||
1, // svg is scaled on root
|
1, // svg is scaled on root
|
||||||
includeLogo,
|
includeLogo,
|
||||||
);
|
);
|
||||||
|
@ -383,19 +383,23 @@ const addContentBackgroundToSvg = ({
|
||||||
svgRoot.appendChild(rect);
|
svgRoot.appendChild(rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addLogoToSvg = (
|
const addLogoToSvg = ({
|
||||||
svgRoot: SVGSVGElement,
|
svgRoot,
|
||||||
normalizedCanvasDimensions: Dimensions,
|
canvasDimensions,
|
||||||
logoImage: SVGSVGElement,
|
logoImage,
|
||||||
theme: AppState["theme"],
|
theme,
|
||||||
) => {
|
}: {
|
||||||
|
svgRoot: SVGSVGElement;
|
||||||
|
canvasDimensions: Dimensions;
|
||||||
|
logoImage: SVGSVGElement;
|
||||||
|
theme: AppState["theme"];
|
||||||
|
}) => {
|
||||||
const logoWidth = parseFloat(logoImage.getAttribute("width") || "0");
|
const logoWidth = parseFloat(logoImage.getAttribute("width") || "0");
|
||||||
const logoHeight = parseFloat(logoImage.getAttribute("height") || "0");
|
const logoHeight = parseFloat(logoImage.getAttribute("height") || "0");
|
||||||
|
|
||||||
const x = (normalizedCanvasDimensions.width - logoWidth) / 2;
|
const x = (canvasDimensions.width - logoWidth) / 2;
|
||||||
const y =
|
const y =
|
||||||
normalizedCanvasDimensions.height -
|
canvasDimensions.height - (logoHeight + FANCY_BG_LOGO_BOTTOM_PADDING);
|
||||||
(logoHeight + FANCY_BG_LOGO_BOTTOM_PADDING);
|
|
||||||
|
|
||||||
logoImage.setAttribute("x", `${x}`);
|
logoImage.setAttribute("x", `${x}`);
|
||||||
logoImage.setAttribute("y", `${y}`);
|
logoImage.setAttribute("y", `${y}`);
|
||||||
|
@ -440,7 +444,7 @@ export const applyFancyBackgroundOnSvg = async ({
|
||||||
svgRoot,
|
svgRoot,
|
||||||
contentSize,
|
contentSize,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
dimensions: {
|
canvasDimensions: {
|
||||||
width: canvasDimensions.width,
|
width: canvasDimensions.width,
|
||||||
height: canvasDimensions.height,
|
height: canvasDimensions.height,
|
||||||
},
|
},
|
||||||
|
@ -451,14 +455,11 @@ export const applyFancyBackgroundOnSvg = async ({
|
||||||
const logoImage = await loadSVGElement(
|
const logoImage = await loadSVGElement(
|
||||||
theme === THEME.DARK ? EXPORT_LOGO_URL_DARK : EXPORT_LOGO_URL,
|
theme === THEME.DARK ? EXPORT_LOGO_URL_DARK : EXPORT_LOGO_URL,
|
||||||
);
|
);
|
||||||
addLogoToSvg(
|
addLogoToSvg({
|
||||||
svgRoot,
|
svgRoot,
|
||||||
{
|
canvasDimensions,
|
||||||
width: canvasDimensions.width,
|
|
||||||
height: canvasDimensions.height,
|
|
||||||
},
|
|
||||||
logoImage,
|
logoImage,
|
||||||
theme,
|
theme,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue