mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
chore: render debug elements
This commit is contained in:
parent
efbe0373b0
commit
0f1bfeec29
2 changed files with 18 additions and 1 deletions
|
|
@ -90,6 +90,9 @@ function drawStateLabels(list) {
|
|||
|
||||
const pathPoints = [[x1, y1], state.pole, [x2, y2]];
|
||||
if (x1 > x2) pathPoints.reverse();
|
||||
|
||||
DEBUG && drawPoint(state.pole, {color: "red", radius: 2});
|
||||
DEBUG && drawPath(pathPoints, {color: "red", width: 1});
|
||||
labelPaths.push([state.i, pathPoints]);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +105,7 @@ function drawStateLabels(list) {
|
|||
const [x, y] = [point.x + distance * dx, point.y + distance * dy];
|
||||
const cellId = findCell(x, y, DISTANCE_STEP);
|
||||
|
||||
// drawPoint([x, y], {color: cellId && isPassable(cellId) ? "blue" : "red", radius: 0.8});
|
||||
DEBUG && drawPoint([x, y], {color: cellId && isPassable(cellId) ? "blue" : "red", radius: 0.8});
|
||||
|
||||
if (!cellId || !isPassable(cellId)) break;
|
||||
distance += DISTANCE_STEP;
|
||||
|
|
|
|||
|
|
@ -56,3 +56,17 @@ function drawRouteConnections() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawPoint([x, y], {color = "red", radius = 0.5}) {
|
||||
debug.append("circle").attr("cx", x).attr("cy", y).attr("r", radius).attr("fill", color);
|
||||
}
|
||||
|
||||
function drawPath(points, {color = "red", width = 0.5}) {
|
||||
const lineGen = d3.line().curve(d3.curveBundle);
|
||||
debug
|
||||
.append("path")
|
||||
.attr("d", round(lineGen(points)))
|
||||
.attr("stroke", color)
|
||||
.attr("stroke-width", width)
|
||||
.attr("fill", "none");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue