示例#1
0
文件: mandel.go 项目: ineol/mandelgo
func handleChans(im *image.RGBA, ch <-chan point) {
	counter := 0
	pixCount := im.Height() * im.Width()

	for counter < pixCount {
		counter += 1
		p := <-ch
		im.Pixel[p.x][p.y] = p.color
	}
}
示例#2
0
文件: mandel.go 项目: ineol/mandelgo
func Mandelbrot(im *image.RGBA, lineMin, lineMax int, vpx, vpy, d float64, ch chan<- point) {
	width := float64(im.Width())
	height := float64(im.Height())
	for i := lineMin; i < lineMax; i++ {
		for j := 0; j < im.Height(); j++ {
			x0 := float64(i)/(width/d) - d/2.0 + vpx
			y0 := float64(j)/(height/d) - d/2.0 + vpy
			ch <- point{i, j, getPixelAt(y0, x0)}
		}
	}
}