Skip to content

Commit

Permalink
Update padding according to grid size
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennard Schober committed May 8, 2024
1 parent d4a750a commit 5c05fda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/scripts3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let animationGrid = 0;
let weightGrid = 0;
let cellWidth = 25;
let cellHeight = 25;
const padding = 1;
let padding = 1;
let sRow, sCol, tRow, tCol = 0;
let canvas = document.getElementById('pathfindingCanvas');
let ctx = canvas.getContext('2d');
Expand Down Expand Up @@ -434,6 +434,9 @@ function getMousePos(evt) {
document.getElementById("sizeSlider").oninput = function () {
gridSize = 2 * this.value + 1;

// adjust padding
padding = 2 + (0 - 2) / (301 - 21) * (gridSize - 21);

let numCols = gridSize;
let numRows = Math.floor(numCols * winHeight / winWidth);

Expand All @@ -452,6 +455,8 @@ document.getElementById("sizeSlider").oninput = function () {

anchorFixed = false;

console.log(padding);

resetCanvas();
}

Expand Down

0 comments on commit 5c05fda

Please sign in to comment.