Compare commits

..

1 Commits

Author SHA1 Message Date
Aakansha Doshi cacfc7a0b0 test 2023-07-31 20:23:51 +05:30
4 changed files with 13 additions and 54 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM node:18 AS build
FROM node:14-alpine AS build
WORKDIR /opt/node_app
+1
View File
@@ -1843,6 +1843,7 @@ class App extends React.Component<AppProps, AppState> {
componentDidUpdate(prevProps: AppProps, prevState: AppState) {
this.updateEmbeddables();
console.log("HEYYY BEFORE VITE AUTOMATIC RELOAD!!");
if (
!this.state.showWelcomeScreen &&
!this.scene.getElementsIncludingDeleted().length
+11 -37
View File
@@ -162,52 +162,23 @@ const fillCircle = (
const strokeGrid = (
context: CanvasRenderingContext2D,
gridSize: number,
scrollX: number,
scrollY: number,
zoom: Zoom,
offsetX: number,
offsetY: number,
width: number,
height: number,
) => {
const BOLD_LINE_FREQUENCY = 5;
enum GridLineColor {
Bold = "#cccccc",
Regular = "#e5e5e5",
}
const offsetX =
-Math.round(zoom.value / gridSize) * gridSize + (scrollX % gridSize);
const offsetY =
-Math.round(zoom.value / gridSize) * gridSize + (scrollY % gridSize);
const lineWidth = Math.min(1 / zoom.value, 1);
const spaceWidth = 1 / zoom.value;
const lineDash = [lineWidth * 3, spaceWidth + (lineWidth + spaceWidth)];
context.save();
context.lineWidth = lineWidth;
context.strokeStyle = "rgba(0,0,0,0.1)";
context.beginPath();
for (let x = offsetX; x < offsetX + width + gridSize * 2; x += gridSize) {
const isBold =
Math.round(x - scrollX) % (BOLD_LINE_FREQUENCY * gridSize) === 0;
context.beginPath();
context.setLineDash(isBold ? [] : lineDash);
context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular;
context.moveTo(x, offsetY - gridSize);
context.lineTo(x, offsetY + height + gridSize * 2);
context.stroke();
}
for (let y = offsetY; y < offsetY + height + gridSize * 2; y += gridSize) {
const isBold =
Math.round(y - scrollY) % (BOLD_LINE_FREQUENCY * gridSize) === 0;
context.beginPath();
context.setLineDash(isBold ? [] : lineDash);
context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular;
context.moveTo(offsetX - gridSize, y);
context.lineTo(offsetX + width + gridSize * 2, y);
context.stroke();
}
context.stroke();
context.restore();
};
@@ -454,9 +425,12 @@ export const _renderScene = ({
strokeGrid(
context,
appState.gridSize,
renderConfig.scrollX,
renderConfig.scrollY,
renderConfig.zoom,
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
appState.gridSize +
(renderConfig.scrollX % appState.gridSize),
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
appState.gridSize +
(renderConfig.scrollY % appState.gridSize),
normalizedCanvasWidth / renderConfig.zoom.value,
normalizedCanvasHeight / renderConfig.zoom.value,
);
-16
View File
@@ -15,18 +15,6 @@ import Scene from "./Scene";
export const SVG_EXPORT_TAG = `<!-- svg-source:excalidraw -->`;
const createScene = (
elements: readonly NonDeletedExcalidrawElement[],
): Scene | null => {
if (!elements || Scene.getScene(elements[0])) {
return null;
}
const scene = new Scene();
scene.replaceAllElements(elements);
elements?.forEach((el) => Scene.mapElementToScene(el, scene));
return scene;
};
export const exportToCanvas = async (
elements: readonly NonDeletedExcalidrawElement[],
appState: AppState,
@@ -50,7 +38,6 @@ export const exportToCanvas = async (
return { canvas, scale: appState.exportScale };
},
) => {
const scene = createScene(elements);
const [minX, minY, width, height] = getCanvasSize(elements, exportPadding);
const { canvas, scale = 1 } = createCanvas(width, height);
@@ -92,7 +79,6 @@ export const exportToCanvas = async (
},
});
scene?.destroy();
return canvas;
};
@@ -119,7 +105,6 @@ export const exportToSvg = async (
exportScale = 1,
exportEmbedScene,
} = appState;
const scene = createScene(elements);
let metadata = "";
if (exportEmbedScene) {
try {
@@ -232,7 +217,6 @@ export const exportToSvg = async (
renderEmbeddables: opts?.renderEmbeddables,
});
scene?.destroy();
return svgRoot;
};