fix: cleanup after rebase

This commit is contained in:
Arnošt Pleskot 2023-08-18 19:00:38 +02:00
parent c2870a6df5
commit 5ff4e0d640
No known key found for this signature in database
3 changed files with 14 additions and 29 deletions

View File

@ -402,6 +402,7 @@ const bootstrapCanvas = ({
theme, theme,
isExporting, isExporting,
viewBackgroundColor, viewBackgroundColor,
exportWithFancyBackground,
}: { }: {
canvas: HTMLCanvasElement; canvas: HTMLCanvasElement;
scale: number; scale: number;
@ -410,6 +411,7 @@ const bootstrapCanvas = ({
theme?: AppState["theme"]; theme?: AppState["theme"];
isExporting?: StaticCanvasRenderConfig["isExporting"]; isExporting?: StaticCanvasRenderConfig["isExporting"];
viewBackgroundColor?: StaticCanvasAppState["viewBackgroundColor"]; viewBackgroundColor?: StaticCanvasAppState["viewBackgroundColor"];
exportWithFancyBackground?: boolean;
}): CanvasRenderingContext2D => { }): CanvasRenderingContext2D => {
const context = canvas.getContext("2d")!; const context = canvas.getContext("2d")!;
@ -419,7 +421,6 @@ const bootstrapCanvas = ({
if (isExporting && theme === "dark") { if (isExporting && theme === "dark") {
context.filter = THEME_FILTER; context.filter = THEME_FILTER;
} }
// Paint background // Paint background
if (typeof viewBackgroundColor === "string") { if (typeof viewBackgroundColor === "string") {
const hasTransparence = const hasTransparence =
@ -434,7 +435,7 @@ const bootstrapCanvas = ({
context.fillStyle = viewBackgroundColor; context.fillStyle = viewBackgroundColor;
context.fillRect(0, 0, normalizedWidth, normalizedHeight); context.fillRect(0, 0, normalizedWidth, normalizedHeight);
context.restore(); context.restore();
} else { } else if (!exportWithFancyBackground) {
context.clearRect(0, 0, normalizedWidth, normalizedHeight); context.clearRect(0, 0, normalizedWidth, normalizedHeight);
} }
@ -924,6 +925,7 @@ const _renderStaticScene = ({
theme: appState.theme, theme: appState.theme,
isExporting, isExporting,
viewBackgroundColor: appState.viewBackgroundColor, viewBackgroundColor: appState.viewBackgroundColor,
exportWithFancyBackground: renderConfig.exportWithFancyBackground,
}); });
// Apply zoom // Apply zoom

View File

@ -74,28 +74,6 @@ export const exportToCanvas = async (
const onlyExportingSingleFrame = isOnlyExportingSingleFrame(elements); const onlyExportingSingleFrame = isOnlyExportingSingleFrame(elements);
const renderConfig = {
viewBackgroundColor:
exportBackground && !exportWithFancyBackground
? viewBackgroundColor
: null,
scrollX: -minX + (onlyExportingSingleFrame ? 0 : padding),
scrollY: -minY + (onlyExportingSingleFrame ? 0 : padding),
zoom: defaultAppState.zoom,
remotePointerViewportCoords: {},
remoteSelectedElementIds: {},
shouldCacheIgnoreZoom: false,
remotePointerUsernames: {},
remotePointerUserStates: {},
theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT,
imageCache,
renderScrollbars: false,
renderSelection: false,
renderGrid: false,
isExporting: true,
exportBackgroundImage: appState.fancyBackgroundImageKey,
};
if ( if (
exportWithFancyBackground && exportWithFancyBackground &&
appState.fancyBackgroundImageKey !== "solid" appState.fancyBackgroundImageKey !== "solid"
@ -105,7 +83,7 @@ export const exportToCanvas = async (
fancyBackgroundImageKey: appState.fancyBackgroundImageKey, fancyBackgroundImageKey: appState.fancyBackgroundImageKey,
backgroundColor: viewBackgroundColor, backgroundColor: viewBackgroundColor,
exportScale: scale, exportScale: scale,
theme: renderConfig.theme, theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT,
}); });
} }
@ -117,17 +95,21 @@ export const exportToCanvas = async (
scale, scale,
appState: { appState: {
...appState, ...appState,
viewBackgroundColor: exportBackground ? viewBackgroundColor : null, viewBackgroundColor:
scrollX: -minX + (onlyExportingSingleFrame ? 0 : exportPadding), exportBackground && !exportWithFancyBackground
scrollY: -minY + (onlyExportingSingleFrame ? 0 : exportPadding), ? viewBackgroundColor
: null,
scrollX: -minX + (onlyExportingSingleFrame ? 0 : padding),
scrollY: -minY + (onlyExportingSingleFrame ? 0 : padding),
zoom: defaultAppState.zoom, zoom: defaultAppState.zoom,
shouldCacheIgnoreZoom: false, shouldCacheIgnoreZoom: false,
theme: appState.exportWithDarkMode ? "dark" : "light", theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT,
}, },
renderConfig: { renderConfig: {
imageCache, imageCache,
renderGrid: false, renderGrid: false,
isExporting: true, isExporting: true,
exportWithFancyBackground,
}, },
}); });

View File

@ -18,6 +18,7 @@ export type StaticCanvasRenderConfig = {
/** when exporting the behavior is slightly different (e.g. we can't use /** when exporting the behavior is slightly different (e.g. we can't use
CSS filters), and we disable render optimizations for best output */ CSS filters), and we disable render optimizations for best output */
isExporting: boolean; isExporting: boolean;
exportWithFancyBackground?: boolean;
}; };
export type InteractiveCanvasRenderConfig = { export type InteractiveCanvasRenderConfig = {