road tweak

This commit is contained in:
33333-33333 2026-05-27 00:13:13 +09:00
commit 0359bb2445
5 changed files with 1266 additions and 200 deletions

View file

@ -208,10 +208,13 @@ function vectorPath(path) {
if (cached) return cached;
const points = path.map(([x, y]) => [x * CELL_SIZE + CELL_SIZE / 2, y * CELL_SIZE + CELL_SIZE / 2]);
const simplified = simplifyRdp(points, CELL_SIZE * 0.34);
const smoothed = chaikin(simplified, path.length > 6 ? 1 : 0, false);
pathVectorCache.set(path, smoothed);
return smoothed;
// Transport routes are already cost-routed on the raster grid. A large RDP
// tolerance erases those small valley/contour bends and makes roads look like
// ruler-straight overlays, so smooth first and simplify only lightly.
const smoothedBase = chaikin(points, path.length > 8 ? 1 : 0, false);
const simplified = simplifyRdp(smoothedBase, CELL_SIZE * 0.14);
pathVectorCache.set(path, simplified);
return simplified;
}
function drawPolylinePoints(ctx, points) {
@ -636,7 +639,8 @@ function drawDebugCells(ctx, map, field, color) {
const i = indexOf(x, y);
const debugMask = map.humanRegionMask || map.prefectureMask;
if (!debugMask[i] || map.sea[i]) continue;
const v = clamp(field[i] || 0, 0, 1);
const raw = field[i] || 0;
const v = clamp(raw > 1 ? raw / 255 : raw, 0, 1);
if (v <= 0.12) continue;
ctx.fillStyle = color(v);
ctx.fillRect(x * CELL_SIZE, y * CELL_SIZE, CELL_SIZE, CELL_SIZE);
@ -917,7 +921,10 @@ export function drawMap(canvas, map, options) {
for (const path of map.premodernRoads) drawPath(ctx, path, "rgba(210, 210, 210, 0.7)", 2.5);
}
if (showMinorRoads) {
for (const path of map.minorRoads || []) drawPath(ctx, path, "rgba(205, 205, 205, 0.60)", 2.35);
// Local roads need a visible casing on pale green lowland/farmland tiles.
// Keep the fill light, but use a warmer grey outline rather than a nearly
// invisible white-on-green stroke.
for (const path of map.minorRoads || []) drawPath(ctx, path, "rgba(132, 126, 112, 0.72)", 2.75);
}
if (showRoads) {
for (const path of map.nationalRoads) drawPath(ctx, path, "rgba(190, 175, 140, 1)", 3.8);
@ -939,7 +946,7 @@ export function drawMap(canvas, map, options) {
for (const path of map.premodernRoads) drawPath(ctx, path, "rgba(255, 255, 255, 1)", 1.2, false);
}
if (showMinorRoads) {
for (const path of map.minorRoads || []) drawPath(ctx, path, "rgba(255, 255, 255, 0.94)", 1.1, false);
for (const path of map.minorRoads || []) drawPath(ctx, path, "rgba(255, 253, 244, 0.98)", 1.25, false);
}
if (showRoads) {
for (const path of map.nationalRoads) drawPath(ctx, path, "rgba(245, 225, 130, 1)", 2.0);