add precaching for painting
This commit is contained in:
parent
65e3dc9ef8
commit
c0e78d8a3d
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…
Reference in New Issue