improoooved
This commit is contained in:
parent
440dba2f09
commit
0990b98436
5 changed files with 358 additions and 2795 deletions
24
mapPatchContext.js
Normal file
24
mapPatchContext.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
export function createPatchContext({ world, rects, candidateWindow, seed, patchAlpha, sourceIndexForWorld, worldIndex }) {
|
||||
const writeRect = rects?.writeRect;
|
||||
const writeCells = [];
|
||||
if (world && writeRect && typeof patchAlpha === "function" && typeof sourceIndexForWorld === "function" && typeof worldIndex === "function") {
|
||||
for (let y = writeRect.y0; y < writeRect.y1; y++) {
|
||||
for (let x = writeRect.x0; x < writeRect.x1; x++) {
|
||||
const wi = worldIndex(world, x, y);
|
||||
if (wi < 0) continue;
|
||||
const si = sourceIndexForWorld(rects, candidateWindow, x, y);
|
||||
if (si < 0) continue;
|
||||
const alpha = patchAlpha(x, y, rects, seed);
|
||||
if (alpha <= 0.005) continue;
|
||||
writeCells.push({ x, y, wi, si, alpha });
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
world,
|
||||
rects,
|
||||
candidateWindow,
|
||||
seed,
|
||||
writeCells,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue