Experimenting with adding colors

This commit is contained in:
Steven Polley 2018-07-31 15:28:28 -06:00
parent a9b8108924
commit 81765e2a16
2 changed files with 7 additions and 6 deletions

View File

@ -19,13 +19,13 @@ const (
Brighten = 1024
)
func mandelbrot(c complex128) uint16 {
func mandelbrot(c complex128) uint8 {
var z complex128
for i := 0; i < Iterations; i++ {
z = z*z + c
if cmplx.IsNaN(z) {
return uint16(i)
return uint8(i)
}
}
@ -33,7 +33,7 @@ func mandelbrot(c complex128) uint16 {
}
type pixel struct {
out *image.Gray16
out *image.RGBA
x, y int
tileX, tileY int64
tileZoom uint8
@ -50,7 +50,8 @@ func computeThread() {
(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()
}
@ -95,7 +96,7 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
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 y := 0; y < Size; y++ {

View File

@ -24,7 +24,7 @@ var mandelbrotTypeOptions = {
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(256, 256),
maxZoom: (1<<8) - 1,
maxZoom: (1<<16) - 1,
minZoom: 0,
name: 'Mandelbrot'
};