Resolution Scaling

This commit is contained in:
2026-02-25 21:54:44 +02:00
parent 75788aae84
commit 21e906826d

16
main.go
View File

@@ -8,9 +8,9 @@ import (
"test-maze/mazer" "test-maze/mazer"
) )
const SIZE_X = 13 const SIZE_X = 21
const SIZE_Y = 13 const SIZE_Y = 21
const CELL_SCALE = 1 const SCALE_FACTOR = 5
const COLOR_SOLUTION_PATH = true const COLOR_SOLUTION_PATH = true
func main() { func main() {
@@ -21,16 +21,16 @@ func main() {
solutionPath = mazer.FindSolutionPath(matrix) solutionPath = mazer.FindSolutionPath(matrix)
} }
img := image.NewRGBA(image.Rect(0, 0, SIZE_X*CELL_SCALE, SIZE_Y*CELL_SCALE)) img := image.NewRGBA(image.Rect(0, 0, SIZE_X*SCALE_FACTOR, SIZE_Y*SCALE_FACTOR))
white := color.RGBA{R: 255, G: 255, B: 255, A: 255} white := color.RGBA{R: 255, G: 255, B: 255, A: 255}
black := color.RGBA{R: 0, G: 0, B: 0, A: 255} black := color.RGBA{R: 0, G: 0, B: 0, A: 255}
green := color.RGBA{R: 0, G: 180, B: 0, A: 255} green := color.RGBA{R: 0, G: 180, B: 0, A: 255}
for cellY := 0; cellY < SIZE_Y; cellY++ { for cellY := 0; cellY < SIZE_Y; cellY++ {
startY := cellY * CELL_SCALE startY := cellY * SCALE_FACTOR
for cellX := 0; cellX < SIZE_X; cellX++ { for cellX := 0; cellX < SIZE_X; cellX++ {
startX := cellX * CELL_SCALE startX := cellX * SCALE_FACTOR
p := black p := black
if matrix[cellY][cellX] == 1 { if matrix[cellY][cellX] == 1 {
@@ -40,9 +40,9 @@ func main() {
} }
} }
for dy := 0; dy < CELL_SCALE; dy++ { for dy := 0; dy < SCALE_FACTOR; dy++ {
row := img.Pix[(startY+dy)*img.Stride:] row := img.Pix[(startY+dy)*img.Stride:]
for dx := 0; dx < CELL_SCALE; dx++ { for dx := 0; dx < SCALE_FACTOR; dx++ {
offset := (startX + dx) * 4 offset := (startX + dx) * 4
row[offset+0] = p.R row[offset+0] = p.R
row[offset+1] = p.G row[offset+1] = p.G