funcnewton_iter(z complex128)int { for i := 0; i < 255; i += 9 { z1 := z - newton_f(z)/newton_df(z) if cmplx.Abs(z1-z) < _NEWTON_E { return i } z = z1 } return255 }
funcnewton(img *image.RGBA, limit int) { for i := 0; i < limit; i++ { zx := _NEWTON_MAP_MAX*float64(i)/float64(limit) - _NEWTON_MAP_MAX/2 for j := 0; j < limit; j++ { zy := _NEWTON_MAP_MAX*float64(j)/float64(limit) - _NEWTON_MAP_MAX/2 gray := uint8(newton_iter(complex(zx, zy))) point(img, i, j, color.Gray{gray}) } } }