Experimenting with adding colors
This commit is contained in:
parent
a9b8108924
commit
81765e2a16
@ -19,13 +19,13 @@ const (
|
|||||||
Brighten = 1024
|
Brighten = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
func mandelbrot(c complex128) uint16 {
|
func mandelbrot(c complex128) uint8 {
|
||||||
var z complex128
|
var z complex128
|
||||||
|
|
||||||
for i := 0; i < Iterations; i++ {
|
for i := 0; i < Iterations; i++ {
|
||||||
z = z*z + c
|
z = z*z + c
|
||||||
if cmplx.IsNaN(z) {
|
if cmplx.IsNaN(z) {
|
||||||
return uint16(i)
|
return uint8(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ func mandelbrot(c complex128) uint16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type pixel struct {
|
type pixel struct {
|
||||||
out *image.Gray16
|
out *image.RGBA
|
||||||
x, y int
|
x, y int
|
||||||
tileX, tileY int64
|
tileX, tileY int64
|
||||||
tileZoom uint8
|
tileZoom uint8
|
||||||
@ -50,7 +50,8 @@ func computeThread() {
|
|||||||
(float64(p.y)/Size+float64(p.tileY))/float64(uint(1<<p.tileZoom)),
|
(float64(p.y)/Size+float64(p.tileY))/float64(uint(1<<p.tileZoom)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
p.out.SetGray16(p.x, p.y, color.Gray16{val * Brighten})
|
p.out.SetRGBA(p.x, p.y, color.RGBA{50, val, val*2 - 128, 255})
|
||||||
|
// p.out.SetGray16(p.x, p.y, color.Gray16{val * Brighten})
|
||||||
|
|
||||||
p.wg.Done()
|
p.wg.Done()
|
||||||
}
|
}
|
||||||
@ -95,7 +96,7 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
wg.Add(Size * Size)
|
wg.Add(Size * Size)
|
||||||
|
|
||||||
img := image.NewGray16(image.Rect(0, 0, Size, Size))
|
img := image.NewRGBA(image.Rect(0, 0, Size, Size))
|
||||||
|
|
||||||
for x := 0; x < Size; x++ {
|
for x := 0; x < Size; x++ {
|
||||||
for y := 0; y < Size; y++ {
|
for y := 0; y < Size; y++ {
|
||||||
|
@ -24,7 +24,7 @@ var mandelbrotTypeOptions = {
|
|||||||
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
|
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
|
||||||
},
|
},
|
||||||
tileSize: new google.maps.Size(256, 256),
|
tileSize: new google.maps.Size(256, 256),
|
||||||
maxZoom: (1<<8) - 1,
|
maxZoom: (1<<16) - 1,
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
name: 'Mandelbrot'
|
name: 'Mandelbrot'
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user