summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-04-13 10:59:06 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-04-13 10:59:06 -0700
commitfd356010a54aead702b55f2a2b02956015e87215 (patch)
tree08bfbed7f77cd1fdeebc451d73763ede65bd9e73
parent5ac6a72cf9be60addc5872a869669f86e08c7e36 (diff)
downloadmandelbrot-main.tar.zst
Use the cool half-character trick from icatHEADmain
-rw-r--r--mandelbrot.go12
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
}
}