From fd356010a54aead702b55f2a2b02956015e87215 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 13 Apr 2025 10:59:06 -0700 Subject: Use the cool half-character trick from icat --- mandelbrot.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mandelbrot.go') 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 } } -- cgit v1.3.1