From 3543290042033cf85ceef8610040d5e1afa20298 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Tue, 3 Nov 2026 10:59:27 +0100 Subject: [PATCH] feat: map forests as dense clusters of small firs (one symbol per forest field), shallows along the shores, lower and darker mountains Co-Authored-By: Claude Opus 5.5 --- app/components/map/Land.vue | 97 +++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 31 deletions(-) diff --git a/app/components/map/Land.vue b/app/components/map/Land.vue index 6667ad2..2c7de8f 100644 --- a/app/components/map/Land.vue +++ b/app/components/map/Land.vue @@ -20,12 +20,39 @@ interface Field { x: number y: number ground: Ground - /** Trees as [x, y, size] in the field's 100 × 100 box, back to front. */ - trees: [number, number, number][] + /** The cluster of firs a forest field wears (a symbol below), by how deep in the forest it lies. */ + forest: string | null /** A mountain's faces, a little different on every field. */ peaks: string[] | null } +// Forests like the Die Stämme map's: dense clusters of small dark firs. Each forest field +// wears one of a few clusters drawn once as a symbol: a few trees at the edge of the forest, +// more further in, a thicket deep inside, darker the deeper. +interface Fir { + x: number + y: number + size: number +} +const DENSITY = [3, 6, 10] +const FIR_COLOURS = [ + { lit: '#3e5034', dark: '#2b3a27' }, + { lit: '#384a30', dark: '#273624' }, + { lit: '#32432c', dark: '#223020' }, +] +const CLUSTERS = DENSITY.flatMap((n, d) => + [0, 1, 2, 3].map((v) => { + const firs: Fir[] = Array.from({ length: n }, (_, i) => ({ + x: 12 + fieldHash(i * 7 + v * 31, d * 13 + 1) * 76, + y: 18 + fieldHash(d * 17 + 3, i * 11 + v * 29) * 70, + size: 0.5 + fieldHash(i + v * 5, d + 9) * 0.28, + })).sort((a, b) => a.y - b.y) + return { id: `map-forest-${d}-${v}`, firs, colours: FIR_COLOURS[d]! } + }), +) +/** Forest floor under the thicker clusters: the grass goes dark there. */ +const FLOOR = ['#656c46', '#606843'] + const pts = (...p: number[]) => p.reduce((s, v, i) => s + (i % 2 ? `,${v.toFixed(1)}` : `${i ? ' ' : ''}${v.toFixed(1)}`), '') /** * A mountain in the field's 100 × 100 box: a big peak and a smaller one behind it, each a lit @@ -37,8 +64,8 @@ function peaks(x: number, y: number): string[] { const q = fieldHash(y, x) const out: string[] = [] for (const [ax, ay, lx, rx, by] of [ - [24 + q * 14, 18 + r * 10, -2, 60, 84], - [48 + r * 12, -14 + q * 14, 14, 100, 94], + [24 + q * 14, 30 + r * 10, 0, 58, 82], + [50 + r * 12, 8 + q * 12, 16, 98, 92], ] as const) { const mx = ax + (rx - ax) * 0.3 const my = by + 4 @@ -53,7 +80,7 @@ function peaks(x: number, y: number): string[] { return out } /** Fills of a mountain's faces, in the order `peaks` returns them: lit, in shadow, bare rock on each. */ -const PEAK_FILLS = ['#827d74', '#5a5751', '#9a958b', '#6e6b65'] +const PEAK_FILLS = ['#78746b', '#55524c', '#8d887f', '#67645e'] const groundOf = (x: number, y: number): Ground => (props.villages.has(`${x}|${y}`) ? 'grass' : groundAt(x, y)) @@ -64,6 +91,7 @@ const fields = computed(() => { // The flat ground: one path per grass shade and one for the lakes, a subpath per run of fields. const flat: Record = {} let shore = '' + let shallows = '' let ripples = '' for (let y = y0; y < y1; y++) { let run: string | null = null @@ -73,7 +101,9 @@ const fields = computed(() => { } for (let x = x0; x <= x1; x++) { const ground = x < x1 ? groundOf(x, y) : null - const fill = ground === null ? null : ground === 'water' ? WATER : GRASS[Math.floor(fieldHash(x, y) * GRASS.length)]! + const depth = ground === 'forest' ? forestDepth(x, y) : 0 + const thick = depth > TERRAIN.forest.above ? (depth > 0.7 ? 2 : 1) : 0 + const fill = ground === null ? null : ground === 'water' ? WATER : thick ? FLOOR[thick - 1]! : GRASS[Math.floor(fieldHash(x, y) * GRASS.length)]! if (fill !== run) { close(x) run = fill @@ -81,54 +111,59 @@ const fields = computed(() => { } if (ground === null || ground === 'grass') continue if (ground === 'water') { - // A sandy shore where the lake meets land, and a ripple. + // A sandy shore where the lake meets land, then the shallows, a step lighter than the deep water. const land = (gx: number, gy: number) => groundOf(gx, gy) !== 'water' - const s = F * 0.09 - if (land(x, y - 1)) shore += `M${x * F} ${y * F}h${F}v${s}h${-F}z` - if (land(x, y + 1)) shore += `M${x * F} ${(y + 1) * F - s}h${F}v${s}h${-F}z` - if (land(x - 1, y)) shore += `M${x * F} ${y * F}h${s}v${F}h${-s}z` - if (land(x + 1, y)) shore += `M${(x + 1) * F - s} ${y * F}h${s}v${F}h${-s}z` + const band = (o: number, s: number) => { + let d = '' + if (land(x, y - 1)) d += `M${x * F} ${y * F + o}h${F}v${s}h${-F}z` + if (land(x, y + 1)) d += `M${x * F} ${(y + 1) * F - o - s}h${F}v${s}h${-F}z` + if (land(x - 1, y)) d += `M${x * F + o} ${y * F}h${s}v${F}h${-s}z` + if (land(x + 1, y)) d += `M${(x + 1) * F - o - s} ${y * F}h${s}v${F}h${-s}z` + return d + } + shallows += band(F * 0.08, F * 0.1) + shore += band(0, F * 0.09) const k = F / 100 ripples += `M${(x * 100 + 28 + fieldHash(x, y) * 30) * k} ${(y * 100 + 50) * k}h${18 * k}M${(x * 100 + 40 + fieldHash(y, x) * 20) * k} ${(y * 100 + 64) * k}h${12 * k}` continue } - // Deeper in a forest, more and bigger trees. - const count = ground === 'forest' ? 2 + Math.round(forestDepth(x, y) * 4) : 0 - const trees = Array.from({ length: count }, (_, i): [number, number, number] => [ - 14 + fieldHash(x * 3 + i, y) * 72, - 28 + fieldHash(x, y * 3 + i) * 56, - 0.75 + fieldHash(x + i, y + i) * 0.5, - ]).sort((a, b) => a[1] - b[1]) - out.push({ x, y, ground, trees, peaks: ground === 'mountain' ? peaks(x, y) : null }) + const forest = ground === 'forest' ? `#map-forest-${thick}-${Math.floor(fieldHash(y, x) * 4)}` : null + out.push({ x, y, ground, forest, peaks: ground === 'mountain' ? peaks(x, y) : null }) } } - return { flat: Object.entries(flat), shore, ripples, raised: out } + return { flat: Object.entries(flat), shore, shallows, ripples, raised: out } })