Shrink 2x and shift down so we can see the whole set
Fix 0x zoom - dividing by 0 is not fun
This commit is contained in:
12
render.go
12
render.go
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Size = 256
|
||||
Size = 128
|
||||
Iterations = (1<<16 - 1) / 128
|
||||
)
|
||||
|
||||
@@ -54,8 +54,8 @@ func computeThread() {
|
||||
for p := range queue {
|
||||
val := mandelbrot(
|
||||
complex(
|
||||
(float64(p.x)/Size+float64(p.tileX))/float64(uint(1<<p.tileZoom)),
|
||||
(float64(p.y)/Size+float64(p.tileY))/float64(uint(1<<p.tileZoom)),
|
||||
(float64(p.x)/Size+float64(p.tileX))/float64(uint(1<<(p.tileZoom-1))),
|
||||
(float64(p.y)/Size+float64(p.tileY))/float64(uint(1<<(p.tileZoom-1))),
|
||||
),
|
||||
)
|
||||
p.out.SetRGBA(p.x, p.y, colors[val])
|
||||
@@ -110,7 +110,8 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for x := 0; x < Size; x++ {
|
||||
for y := 0; y < Size; y++ {
|
||||
queue <- pixel{img, x, y, tileX, tileY, uint16(tileZoom), &wg}
|
||||
|
||||
queue <- pixel{img, x, y, tileX - int64(1<<tileZoom-1) - 1, tileY, uint16(tileZoom), &wg}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
|
||||
/*
|
||||
ip := GetOutboundIP()
|
||||
addLabel(img, 20, 30, fmt.Sprintf("rendered by \n%s", ip.String()))
|
||||
//addLabel(img, 20, 30, fmt.Sprintf("%s/%s/%s.png", components[1], components[2], components[3]))
|
||||
addLabel(img, 20, 30, fmt.Sprintf("%s/%s/%s.png", components[1], components[2], components[3]))
|
||||
*/
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
png.Encode(w, img)
|
||||
@@ -213,6 +214,7 @@ func addLabel(img *image.RGBA, x, y int, label string) {
|
||||
d.DrawString(label)
|
||||
}
|
||||
|
||||
|
||||
func GetOutboundIP() net.IP {
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user