Skip to content

Commit 8bfac89

Browse files
authored
✨| Testing Update
1 parent 47cc7d9 commit 8bfac89

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

VSPLAYER/script.js

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,27 @@ const state = {
3838
};
3939

4040
function resizeCanvas() {
41-
const dpr = window.devicePixelRatio || 1;
42-
const width = canvas.clientWidth * dpr;
43-
const height = canvas.clientHeight * dpr;
44-
if (canvas.width !== width || canvas.height !== height) {
45-
canvas.width = width;
46-
canvas.height = height;
47-
}
41+
const dpr = window.devicePixelRatio || 1;
42+
canvas.width = canvas.clientWidth * dpr;
43+
canvas.height = canvas.clientHeight * dpr;
4844
}
4945

5046
function getBoardMetrics() {
51-
const dpr = window.devicePixelRatio || 1;
52-
const boardSize = Math.min(canvas.width, canvas.height) - PADDING * 2 * dpr;
53-
const spacing = boardSize / ((GRID_SIZE - 1) * Math.SQRT2);
54-
return {
55-
spacing,
56-
centerX: canvas.width / 2,
57-
centerY: canvas.height / 2,
58-
};
47+
const dpr = window.devicePixelRatio || 1;
48+
const boardSize = Math.min(canvas.width, canvas.height) - PADDING * 2 * dpr;
49+
const spacing = boardSize / ((GRID_SIZE - 1) * Math.SQRT2);
50+
return { spacing, centerX: canvas.width / 2, centerY: canvas.height / 2 };
5951
}
6052

6153
function dotPosition(row, col) {
62-
const { spacing, centerX, centerY } = getBoardMetrics();
63-
const offset = (GRID_SIZE - 1) / 2;
64-
const gridX = (col - offset) * spacing;
65-
const gridY = (row - offset) * spacing;
66-
const x = (gridX - gridY) / Math.SQRT2 + centerX;
67-
const y = (gridX + gridY) / Math.SQRT2 + centerY;
68-
return { x, y };
54+
const { spacing, centerX, centerY } = getBoardMetrics();
55+
const offset = (GRID_SIZE - 1) / 2;
56+
const gridX = (col - offset) * spacing;
57+
const gridY = (row - offset) * spacing;
58+
return {
59+
x: (gridX - gridY) / Math.SQRT2 + centerX,
60+
y: (gridX + gridY) / Math.SQRT2 + centerY
61+
};
6962
}
7063

7164
function drawBoxes() {

0 commit comments

Comments
 (0)