refactor: simplify zoom by removing zoom.translation (#4477)

This commit is contained in:
David Luzar 2022-01-29 21:12:44 +01:00 committed by GitHub
parent e4edda4555
commit 79d323fab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 152 additions and 408 deletions

View file

@ -227,10 +227,7 @@ export const renderScene = (
}
// Apply zoom
const zoomTranslationX = renderConfig.zoom.translation.x;
const zoomTranslationY = renderConfig.zoom.translation.y;
context.save();
context.translate(zoomTranslationX, zoomTranslationY);
context.scale(renderConfig.zoom.value, renderConfig.zoom.value);
// Grid
@ -238,14 +235,10 @@ export const renderScene = (
strokeGrid(
context,
appState.gridSize,
-Math.ceil(
zoomTranslationX / renderConfig.zoom.value / appState.gridSize,
) *
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
appState.gridSize +
(renderConfig.scrollX % appState.gridSize),
-Math.ceil(
zoomTranslationY / renderConfig.zoom.value / appState.gridSize,
) *
-Math.ceil(renderConfig.zoom.value / appState.gridSize) *
appState.gridSize +
(renderConfig.scrollY % appState.gridSize),
normalizedCanvasWidth / renderConfig.zoom.value,