add precaching for painting

This commit is contained in:
Martin/Geno 2019-01-05 01:40:24 +01:00
parent 65e3dc9ef8
commit c0e78d8a3d
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 11 additions and 7 deletions

View File

@ -87,14 +87,18 @@ func createSocket(pixelmatrix [][][4]uint32, xstart, ystart int) net.Conn {
}
func paint(conn net.Conn, pixelmatrix [][][4]uint32, xstart, ystart int) {
for {
var prerender [][]byte
for x, row := range pixelmatrix {
for y, pixel := range row {
if pixel[3] != 0 {
msg := fmt.Sprintf("PX %d %d %02x%02x%02x\n", xstart+x, ystart+y, pixel[0], pixel[1], pixel[2])
conn.Write([]byte(msg))
prerender = append(prerender, []byte(msg))
}
}
}
for {
for _, data := range prerender {
conn.Write(data)
}
}
}