feat: map lakes round off their outer corners, shore and shallows following the curve
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3543290042
commit
f47d2b7d11
|
|
@ -92,6 +92,9 @@ const fields = computed(() => {
|
||||||
const flat: Record<string, string> = {}
|
const flat: Record<string, string> = {}
|
||||||
let shore = ''
|
let shore = ''
|
||||||
let shallows = ''
|
let shallows = ''
|
||||||
|
let corners = ''
|
||||||
|
let curvedShore = ''
|
||||||
|
let curvedShallows = ''
|
||||||
let ripples = ''
|
let ripples = ''
|
||||||
for (let y = y0; y < y1; y++) {
|
for (let y = y0; y < y1; y++) {
|
||||||
let run: string | null = null
|
let run: string | null = null
|
||||||
|
|
@ -123,6 +126,22 @@ const fields = computed(() => {
|
||||||
}
|
}
|
||||||
shallows += band(F * 0.08, F * 0.1)
|
shallows += band(F * 0.08, F * 0.1)
|
||||||
shore += band(0, F * 0.09)
|
shore += band(0, F * 0.09)
|
||||||
|
// Where land meets the lake on two sides, the corner is land, rounded off with the shore.
|
||||||
|
const r = F * 0.36
|
||||||
|
for (const [sx, sy] of [[0, 0], [1, 0], [1, 1], [0, 1]] as const) {
|
||||||
|
if (!land(x + (sx ? 1 : -1), y) || !land(x, y + (sy ? 1 : -1))) continue
|
||||||
|
const cx = (x + sx) * F
|
||||||
|
const cy = (y + sy) * F
|
||||||
|
const dx = sx ? -1 : 1
|
||||||
|
const dy = sy ? -1 : 1
|
||||||
|
// The corner square minus a quarter disc, then the shore and the shallows along the quarter circle.
|
||||||
|
const sweep = dx * dy > 0 ? 0 : 1
|
||||||
|
corners += `M${cx} ${cy}h${dx * r}A${r} ${r} 0 0 ${sweep} ${cx} ${cy + dy * r}z`
|
||||||
|
const curve = (outer: number, inner: number) =>
|
||||||
|
`M${cx + dx * r} ${cy + dy * (r - outer)}A${outer} ${outer} 0 0 ${sweep} ${cx + dx * (r - outer)} ${cy + dy * r}L${cx + dx * (r - inner)} ${cy + dy * r}A${inner} ${inner} 0 0 ${1 - sweep} ${cx + dx * r} ${cy + dy * (r - inner)}z`
|
||||||
|
curvedShore += curve(r, r - F * 0.09)
|
||||||
|
curvedShallows += curve(r - F * 0.08, r - F * 0.18)
|
||||||
|
}
|
||||||
const k = F / 100
|
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}`
|
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
|
continue
|
||||||
|
|
@ -131,7 +150,7 @@ const fields = computed(() => {
|
||||||
out.push({ x, y, ground, forest, peaks: ground === 'mountain' ? peaks(x, y) : null })
|
out.push({ x, y, ground, forest, peaks: ground === 'mountain' ? peaks(x, y) : null })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { flat: Object.entries(flat), shore, shallows, ripples, raised: out }
|
return { flat: Object.entries(flat), shore, shallows, corners, curvedShore, curvedShallows, ripples, raised: out }
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -150,6 +169,9 @@ const fields = computed(() => {
|
||||||
<path v-for="[fill, d] in fields.flat" :key="fill" :d="d" :fill="fill" />
|
<path v-for="[fill, d] in fields.flat" :key="fill" :d="d" :fill="fill" />
|
||||||
<path v-if="fields.shallows" :d="fields.shallows" fill="#55676a" />
|
<path v-if="fields.shallows" :d="fields.shallows" fill="#55676a" />
|
||||||
<path v-if="fields.shore" :d="fields.shore" :fill="SHORE" />
|
<path v-if="fields.shore" :d="fields.shore" :fill="SHORE" />
|
||||||
|
<path v-if="fields.corners" :d="fields.corners" :fill="GRASS[0]" />
|
||||||
|
<path v-if="fields.curvedShallows" :d="fields.curvedShallows" fill="#55676a" />
|
||||||
|
<path v-if="fields.curvedShore" :d="fields.curvedShore" :fill="SHORE" />
|
||||||
<path v-if="fields.ripples" :d="fields.ripples" stroke="#6a7a80" :stroke-width="field * 0.03" stroke-linecap="round" />
|
<path v-if="fields.ripples" :d="fields.ripples" stroke="#6a7a80" :stroke-width="field * 0.03" stroke-linecap="round" />
|
||||||
<g v-for="f in fields.raised" :key="`${f.x}|${f.y}`" :transform="`translate(${f.x * field} ${f.y * field}) scale(${field / 100})`">
|
<g v-for="f in fields.raised" :key="`${f.x}|${f.y}`" :transform="`translate(${f.x * field} ${f.y * field}) scale(${field / 100})`">
|
||||||
<template v-if="f.ground === 'hill'">
|
<template v-if="f.ground === 'hill'">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue