reorganized the project

This commit is contained in:
grimsace
2026-03-12 12:22:09 -05:00
parent c0382d6657
commit 302a9aaf74
10 changed files with 2657 additions and 2782 deletions
+1 -41
View File
@@ -874,30 +874,6 @@ func removeSpeckles(mask *[]uint8, bw, bh, minNeighbors int) {
*mask = arr
}
// maskToPoints converts mask to point slice for visualization
func maskToPoints(mask []uint8, bw, bh, minX, minY int) []image.Point {
var pts []image.Point
for y := 0; y < bh; y++ {
for x := 0; x < bw; x++ {
if mask[y*bw+x] == 1 {
pts = append(pts, image.Point{X: x + minX, Y: y + minY})
}
}
}
return pts
}
// clamp01 clamps value to 0..1 range
func clamp01(v float64) float64 {
if v < 0 {
return 0
}
if v > 1 {
return 1
}
return v
}
// GenerateRivers creates rivers flowing across the map from edge to edge
func GenerateRivers(width, height, numRivers int, minWidth, maxWidth, curvyness float64, inputImage image.Image, lakes [][]image.Point, seed int64, heightmap image.Image, riverWidthVariability, riverEdgeRoughness float64) (image.Image, *PixelMask) {
if numRivers == 0 {
@@ -959,7 +935,7 @@ func GenerateRivers(width, height, numRivers int, minWidth, maxWidth, curvyness
if isWater.GetPoint(p) {
if lakeIndex, isLake := lakePixelMap[p]; isLake {
// End river at lake center if it intersects
lakeCenter := findCenter(lakes[lakeIndex])
lakeCenter := averagePoint(lakes[lakeIndex])
r.End = lakeCenter
} else {
// End river at intersection with another river
@@ -1086,22 +1062,6 @@ func calculateRiverPath(start, end image.Point, curvyness, avgDim float64, randS
return bresenhamRiver(controlPoints)
}
// findCenter calculates the center point of a set of pixels
func findCenter(pixels []image.Point) image.Point {
if len(pixels) == 0 {
return image.Point{}
}
var sumX, sumY int
for _, p := range pixels {
sumX += p.X
sumY += p.Y
}
return image.Point{
X: sumX / len(pixels),
Y: sumY / len(pixels),
}
}
// getPointOnEdge returns a random point on the specified map edge
func getPointOnEdge(width, height, edge int, randSrc *rand.Rand) image.Point {
switch edge {