-
-
Save orcaman/519f8f9f228d8efc9f69ec6f4ff3cfff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
flag.Parse() | |
log.Printf("coloring method: %s", *coloringMethod) | |
log.Printf("concurrency level: %d", *concurrencyLevel) | |
sem = make(chan bool, *concurrencyLevel) | |
... | |
... | |
} | |
func renderImage() { | |
for i := 0; i < imHeight; i++ { | |
for j := 0; j < imWidth; j++ { | |
plotPixel(complex(float64(i), float64(j))) | |
currentPixel++ | |
} | |
} | |
for i := 0; i < cap(sem); i++ { | |
sem <- true | |
} | |
} | |
// check if c belongs to set, assign color accordingly and plot | |
func plotPixel(c complex128) { | |
sem <- true | |
switch *coloringMethod { | |
case "ml": | |
go func(c complex128) { | |
res := getColorFromMLMandelbrot(c) | |
<-sem | |
plot(res.C, res.Color) | |
}(c) | |
case "classic": | |
go func(c complex128) { | |
res := getColorFromClassicMandelbrot(c) | |
<-sem | |
plot(res.C, res.Color) | |
}(c) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment