Move color step and xpos, ypos to variables scoped in main
This commit is contained in:
		
							
								
								
									
										51
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								main.go
									
									
									
									
									
								
							@@ -16,16 +16,14 @@ import (
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	colorPalette string
 | 
			
		||||
	colorStep    float64
 | 
			
		||||
	xpos, ypos   float64
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var waitGroup sync.WaitGroup
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	flag.Float64Var(&colorStep, "step", 12000, "Color smooth step. Value should be greater than iteration count, otherwise the value will be adjusted to the iteration count.")
 | 
			
		||||
	flag.Float64Var(&xpos, "xpos", -0.00275, "Point position on the real axis (defined on `x` axis)")
 | 
			
		||||
	flag.Float64Var(&ypos, "ypos", 0.78912, "Point position on the imaginary axis (defined on `y` axis)")
 | 
			
		||||
	//flag.Float64Var(&xpos, "xpos", -0.00275, "Point position on the real axis (defined on `x` axis)")
 | 
			
		||||
	//flag.Float64Var(&ypos, "ypos", 0.78912, "Point position on the imaginary axis (defined on `y` axis)")
 | 
			
		||||
 | 
			
		||||
	flag.StringVar(&colorPalette, "palette", "Plan9", "Hippi | Plan9 | AfternoonBlue | SummerBeach | Biochimist | Fiesta")
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
}
 | 
			
		||||
@@ -33,11 +31,17 @@ func init() {
 | 
			
		||||
func main() {
 | 
			
		||||
 | 
			
		||||
	//var escapeRadius float64 = 0.125689
 | 
			
		||||
	var escapeRadius float64 = -0.01
 | 
			
		||||
	maxIteration := 800
 | 
			
		||||
	//var escapeRadius float64 = 0
 | 
			
		||||
	var escapeRadius float64 = 4
 | 
			
		||||
	var colorStep float64 = 12000
 | 
			
		||||
	//var xpos float64 = -0.01925
 | 
			
		||||
	//var ypos float64 = 0.796272
 | 
			
		||||
	var xpos float64 = -1.0
 | 
			
		||||
	var ypos float64 = -1.0
 | 
			
		||||
	maxIteration := 2000
 | 
			
		||||
	imageSmoothness := 1
 | 
			
		||||
	width := 1920
 | 
			
		||||
	height := 1080
 | 
			
		||||
	width := 640
 | 
			
		||||
	height := 480
 | 
			
		||||
 | 
			
		||||
	if colorStep < float64(maxIteration) {
 | 
			
		||||
		colorStep = float64(maxIteration)
 | 
			
		||||
@@ -47,10 +51,27 @@ func main() {
 | 
			
		||||
	if len(colors) > 0 {
 | 
			
		||||
		fmt.Println("Rendering images...")
 | 
			
		||||
 | 
			
		||||
		for i := 1; i <= 15000; i++ {
 | 
			
		||||
			render(maxIteration, colors, escapeRadius, imageSmoothness, width, height, fmt.Sprintf("images/%08d.png", i))
 | 
			
		||||
			escapeRadius += 0.001
 | 
			
		||||
			maxIteration += 1
 | 
			
		||||
		for i := 1; i <= 2000; i++ {
 | 
			
		||||
			render(maxIteration, colors, escapeRadius, xpos, ypos, imageSmoothness, width, height, fmt.Sprintf("images/%08d.png", i))
 | 
			
		||||
 | 
			
		||||
			//ypos += 0.00020
 | 
			
		||||
			//xpos -= 0.00010
 | 
			
		||||
 | 
			
		||||
			//	if i%3 == 0 {
 | 
			
		||||
			maxIteration++
 | 
			
		||||
			//	}
 | 
			
		||||
 | 
			
		||||
			if i > 100 {
 | 
			
		||||
				escapeRadius *= 0.995
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if xpos > -1.4 {
 | 
			
		||||
				if i > 100 {
 | 
			
		||||
					//	xpos *= 1.005
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			fmt.Println(xpos)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
@@ -117,8 +138,8 @@ func interpolateColors(paletteCode *string, numberOfColors float64) []color.RGBA
 | 
			
		||||
	return interpolatedColors
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func render(maxIteration int, colors []color.RGBA, escapeRadius float64, imageSmoothness, width, height int, outputFile string) {
 | 
			
		||||
	fmt.Printf("rendering image %s\n", outputFile)
 | 
			
		||||
func render(maxIteration int, colors []color.RGBA, escapeRadius, xpos, ypos float64, imageSmoothness, width, height int, outputFile string) {
 | 
			
		||||
	fmt.Printf("Mandelbrot set escapeRadius=%f image=%s\n", escapeRadius, outputFile)
 | 
			
		||||
 | 
			
		||||
	width = width * imageSmoothness
 | 
			
		||||
	height = height * imageSmoothness
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user