generate the big map
This commit is contained in:
@ -62,14 +62,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
rs[pos] = r
|
rs[pos] = r
|
||||||
}
|
}
|
||||||
// To close mca files
|
bigPicture := image.NewRGBA(image.Rect(min[0]*512, min[1]*512, max[0]*512+512, max[1]*512+512))
|
||||||
defer func() {
|
var bigWg sync.WaitGroup
|
||||||
for pos, r := range rs {
|
|
||||||
if err := r.Close(); err != nil {
|
|
||||||
log.Printf("Close r.%d.%d.mca error: %v", pos[0], pos[1], err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
// draw columns
|
// draw columns
|
||||||
for pos, r := range rs {
|
for pos, r := range rs {
|
||||||
img := image.NewRGBA(image.Rect(0, 0, 32*16, 32*16))
|
img := image.NewRGBA(image.Rect(0, 0, 32*16, 32*16))
|
||||||
@ -110,14 +104,29 @@ func main() {
|
|||||||
log.Printf("Read sector (%d.%d) error: %v", x, z, err)
|
log.Printf("Read sector (%d.%d) error: %v", x, z, err)
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
c <- task{data: data, pos: [2]int{x, z}}
|
c <- task{data: data, pos: [2]int{z, x}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(c)
|
close(c)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
savePng(img, fmt.Sprintf("r.%d.%d.png", pos[0], pos[1]))
|
// Save pictures
|
||||||
|
bigWg.Add(1)
|
||||||
log.Print("Draw: ", pos)
|
log.Print("Draw: ", pos)
|
||||||
|
go func(img image.Image, pos [2]int) {
|
||||||
|
savePng(img, fmt.Sprintf("r.%d.%d.png", pos[0], pos[1]))
|
||||||
|
draw.Draw(
|
||||||
|
bigPicture, image.Rect(pos[0]*512, pos[1]*512, pos[0]*512+512, pos[1]*512+512),
|
||||||
|
img, image.Pt(0, 0), draw.Src,
|
||||||
|
)
|
||||||
|
bigWg.Done()
|
||||||
|
}(img, pos)
|
||||||
|
// To close mca files
|
||||||
|
if err := r.Close(); err != nil {
|
||||||
|
log.Printf("Close r.%d.%d.mca error: %v", pos[0], pos[1], err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
bigWg.Wait()
|
||||||
|
savePng(bigPicture, "maps.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawColumn(column *save.Column) (img *image.RGBA) {
|
func drawColumn(column *save.Column) (img *image.RGBA) {
|
||||||
@ -173,7 +182,7 @@ func drawSection(s *save.Chunk, img *image.RGBA) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c := colors[block.ByID[bid].ID]
|
c := colors[block.ByID[bid].ID]
|
||||||
layerImg.Set(i/16, i%16, c)
|
layerImg.Set(i%16, i/16, c)
|
||||||
}
|
}
|
||||||
draw.Draw(
|
draw.Draw(
|
||||||
img, image.Rect(0, 0, 16, 16),
|
img, image.Rect(0, 0, 16, 16),
|
||||||
|
Reference in New Issue
Block a user