Fix pixel size
This commit is contained in:
parent
b7655cf15d
commit
6f6a1201d8
@ -56,7 +56,6 @@ func GetMaze(imagepath string) (Maze, error) {
|
|||||||
|
|
||||||
image, err := png.Decode(imagereader)
|
image, err := png.Decode(imagereader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Here")
|
|
||||||
return *new(Maze), err
|
return *new(Maze), err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +63,7 @@ func GetMaze(imagepath string) (Maze, error) {
|
|||||||
for y := image.Bounds().Min.Y; y < image.Bounds().Max.Y; y += psize {
|
for y := image.Bounds().Min.Y; y < image.Bounds().Max.Y; y += psize {
|
||||||
newRow := make([]Point, 0)
|
newRow := make([]Point, 0)
|
||||||
for x := image.Bounds().Min.X; x < image.Bounds().Max.X; x += psize {
|
for x := image.Bounds().Min.X; x < image.Bounds().Max.X; x += psize {
|
||||||
|
fmt.Print(x); fmt.Print(" "); fmt.Println(y)
|
||||||
typ := 0
|
typ := 0
|
||||||
switch image.At(x, y) {
|
switch image.At(x, y) {
|
||||||
case color.RGBA{ R: 255, G: 0, B: 0, A: 255 }:
|
case color.RGBA{ R: 255, G: 0, B: 0, A: 255 }:
|
||||||
@ -106,8 +106,12 @@ func PrintMaze(maze Maze) {
|
|||||||
func DeterminePixelSize(image image.Image) int {
|
func DeterminePixelSize(image image.Image) int {
|
||||||
var x, y int
|
var x, y int
|
||||||
color := image.At(x, y)
|
color := image.At(x, y)
|
||||||
for (color == image.At(x, y)) {
|
for {
|
||||||
|
if color != image.At(x, y) {
|
||||||
|
break
|
||||||
|
}
|
||||||
x++
|
x++
|
||||||
|
y++
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,9 @@ type Changeable interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateColor(image image.Image, p getMaze.Point, color color.Color) error {
|
func updateColor(image image.Image, p getMaze.Point, color color.Color) error {
|
||||||
for i := p.Y * 10; i < p.Y * 10 + 10; i++ {
|
psize := getMaze.DeterminePixelSize(image)
|
||||||
for ii := p.X * 10; ii < p.X * 10 + 10; ii++ {
|
for i := p.Y * psize; i < p.Y * psize + psize; i++ {
|
||||||
|
for ii := p.X * psize; ii < p.X * psize + psize; ii++ {
|
||||||
if cimg, ok := image.(Changeable); ok {
|
if cimg, ok := image.(Changeable); ok {
|
||||||
cimg.Set(ii, i, color)
|
cimg.Set(ii, i, color)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user