feat: get grid
This commit is contained in:
@@ -50,4 +50,23 @@ function scrapableHeuristics(maxCountPerPage = 50, minArea = 20000, scrolls = 3,
|
||||
* @typedef {Array<{x: number, y: number}>} Grid
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of grid-aligned {x,y} points.
|
||||
* @param {number} [granularity=0.005] sets the number of generated points
|
||||
* (the higher the granularity, the more points).
|
||||
* @returns {Grid} Array of {x, y} objects.
|
||||
*/
|
||||
function getGrid(startX = 0, startY = 0, granularity = 0.005) {
|
||||
const width = window.innerWidth;
|
||||
const height = window.innerHeight;
|
||||
|
||||
const out = [];
|
||||
for (let x = 0; x < width; x += 1 / granularity) {
|
||||
for (let y = 0; y < height; y += 1 / granularity) {
|
||||
out.push({ x: startX + x, y: startY + y });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user