package main import ( "image" "image/color" "image/png" "log" "math/cmplx" "net/http" "runtime" "strconv" "strings" "sync" ) const ( Size = 256 Iterations = (1<<16 - 1) / Brighten Brighten = 1024 ) func mandelbrot(c complex128) uint16 { var z complex128 for i := 0; i < Iterations; i++ { z = z*z + c if cmplx.IsNaN(z) { return uint16(i) } } return Iterations } type pixel struct { out *image.Gray16 x, y int tileX, tileY int64 tileZoom uint8 wg *sync.WaitGroup } var queue = make(chan pixel) func computeThread() { for p := range queue { val := mandelbrot( complex( (float64(p.x)/Size+float64(p.tileX))/float64(uint(1<