diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-13 10:59:06 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-13 10:59:06 -0700 |
| commit | fd356010a54aead702b55f2a2b02956015e87215 (patch) | |
| tree | 08bfbed7f77cd1fdeebc451d73763ede65bd9e73 | |
| parent | 5ac6a72cf9be60addc5872a869669f86e08c7e36 (diff) | |
| download | mandelbrot-fd356010a54aead702b55f2a2b02956015e87215.tar.zst | |
| -rw-r--r-- | mandelbrot.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mandelbrot.go b/mandelbrot.go index 686625b..0b87ecf 100644 --- a/mandelbrot.go +++ b/mandelbrot.go @@ -46,6 +46,14 @@ func main() { fmt.Fprintln(os.Stderr, err) os.Exit(1) } + height-- // Leave a line for the status bar + + // Try not to stretch Mandelbrot + if yRange*float64(width) <= xRange*float64(height)*5/2 { + height = int(yRange * float64(width) / (xRange * 5 / 2)) + } else { + width = int(xRange * float64(height) * 5 / 2 / yRange) + } xStep := xRange / float64(width) yStep := yRange / float64(height) @@ -54,10 +62,10 @@ func main() { for i := 0; i < height; i++ { x := xMin for j := 0; j < width; j++ { - fmt.Printf("\033[4%dm ", mandelbrot(x, y)) + fmt.Printf("\033[3%dm\033[4%dmâ–€", mandelbrot(x, y), mandelbrot(x, y+yStep/2)) x += xStep } - fmt.Println("\033[49m") + fmt.Println("\033[m") y += yStep } } |
