Created
September 27, 2021 15:28
-
-
Save YonatanKra/cca327e6c30b12982fb27a96b97013f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateBackgroundPaths(matrix) { | |
const wallsPath = new Path2D(); | |
const roadsPath = new Path2D(); | |
const mazePaths = { | |
wallsPath, | |
roadsPath, | |
}; | |
matrix.forEach((pixelsRow, rowIndex) => { | |
const y = rowIndex * PIXEL_RATIO; | |
pixelsRow.forEach((pixel, pixelIndex) => { | |
const x = pixelIndex * PIXEL_RATIO; | |
const currPath = pixel === BLACK ? roadsPath : wallsPath; | |
currPath.rect(x, y, PIXEL_RATIO, PIXEL_RATIO); | |
}); | |
}); | |
return mazePaths; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment