mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor river fendering
This commit is contained in:
parent
6405b442a5
commit
0adc0e883a
6 changed files with 187 additions and 149 deletions
|
|
@ -552,6 +552,20 @@ function getNumberInRange(r) {
|
|||
return count;
|
||||
}
|
||||
|
||||
// return center point of common edge of 2 pack cells
|
||||
function getMiddlePoint(cell1, cell2) {
|
||||
const {cells, vertices} = pack;
|
||||
|
||||
const commonVertices = cells.v[cell1].filter(vertex => vertices.c[vertex].some(cell => cell === cell2));
|
||||
const [x1, y1] = vertices.p[commonVertices[0]];
|
||||
const [x2, y2] = vertices.p[commonVertices[1]];
|
||||
|
||||
const x = (x1 + x2) / 2;
|
||||
const y = (y1 + y2) / 2;
|
||||
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
// helper function non-used for the generation
|
||||
function drawCellsValue(data) {
|
||||
debug.selectAll("text").remove();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue