Browse Source

add precaching for painting

master
Martin/Geno 3 years ago
parent
commit
c0e78d8a3d
No known key found for this signature in database GPG Key ID: 9D7D3C6BFF600C6A
  1. 18
      main.go

18
main.go

@ -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 {
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))
}
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])
prerender = append(prerender, []byte(msg))
}
}
}
for {
for _, data := range prerender {
conn.Write(data)
}
}
}
Loading…
Cancel
Save