mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Refactor getMiddlePoint function to getCloseToEdgePoint
This commit is contained in:
parent
ff27937cc4
commit
e6741b3a3b
4 changed files with 40 additions and 21 deletions
|
|
@ -37,20 +37,6 @@ function getSegmentId(points, point, step = 10) {
|
|||
return minSegment;
|
||||
}
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
function debounce(func, ms) {
|
||||
let isCooldown = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue