This commit is contained in:
semblanceofsense 2025-01-31 21:40:21 -07:00
parent 955e3f1d46
commit 891963a516

View File

@ -5,6 +5,7 @@ import (
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"math"
getMaze "mazesolver/internal/getmaze" getMaze "mazesolver/internal/getmaze"
"os" "os"
) )
@ -20,8 +21,10 @@ func EditMaze(points []getMaze.Point, oldPath, newPath string) (string, error) {
return "", err return "", err
} }
for _, v := range points { for n, v := range points {
updateColor(image, v, color.RGBA{0, 255, 0, 255}) var h float64 = (float64(1) - (((float64(n)) / (float64(len(points)))))) / float64(1.1)
r, g, b := hueToRGB(h)
updateColor(image, v, color.RGBA{uint8(r * 255), uint8(g * 255), uint8(b * 255), 255})
} }
f, err := os.Create(newPath) f, err := os.Create(newPath)
@ -48,3 +51,19 @@ func updateColor(image image.Image, p getMaze.Point, color color.Color) error {
} }
return nil return nil
} }
func hueToRGB(h float64) (float64, float64, float64) {
kr := math.Mod(5+h*6, 6)
kg := math.Mod(3+h*6, 6)
kb := math.Mod(1+h*6, 6)
r := 1 - math.Max(min3(kr, 4-kr, 1), 0)
g := 1 - math.Max(min3(kg, 4-kg, 1), 0)
b := 1 - math.Max(min3(kb, 4-kb, 1), 0)
return r, g, b
}
func min3(a, b, c float64) float64 {
return math.Min(math.Min(a, b), c)
}